![]() |
Tutorial: Ns-2.33 (and nam) on Ubuntu 8.04 (Hardy Heron) |
Since I have been working with ns2 for the last few months in preparation for my thesis I have decided to write a guide on how to install the most recent version of ns2 on the most recent version of ubuntu (at the time of this writing, Monday June 9th, 2008).
I have found many people already who have had difficulty setting it up so maybe this will be of some help to someone. For this tutorial I am assuming you have installed the most recent version of Ubuntu (8.04). (At the time of writing)
Step 1: Update Ubuntu
Since it has already been a month or so since Hardy Heron has been released its probably best, if you haven’t already done so to update Ubuntu. The easiest way I’ve found is to go to System>>Administration>>Update Manager. Alternatively, you can enter this into the terminal:
sudo apt-get update
sudo apt-get upgrade
Step 2: Download all of the required pieces to make ns2 work
Here is a list of archives required for ns2 to work properly (you can download them by clicking the links or just enter all of the commands in the code sections below for automatic download and untar). I saved each archive to the desktop so I could find each one easily but you could use anywhere you like.
Step 2.5: Install Ubuntu Packages
Before installing everything else, I have found that it is helpful to get a few packages from the ubuntu repositories or else it wont build correctly. Grab a cup of coffee it might take a while since kdebase-dev is somewhat large. I’m sure there is a way to do this with fewer packages however I know this works. If anyone figures out exactly which packages are required let me know so I can update this.
sudo apt-get install libx11-dev kdebase-dev
Step 3: Install tcl
wget http://www.jasonernst.com/wp-content/uploads/2008/06/tcl8.4.19-src.tar.gz
tar xvf tcl8.4.19-src.tar.gz
cd tcl8.4.19/unix
./configure
make
sudo make install
Step 4: Install tk
cd ..
cd ..
wget http://www.jasonernst.com/wp-content/uploads/2008/06/tk8.4.19-src.tar.gz
tar xvf tk8.4.19-src.tar.gz
cd tk8.4.19/unix
./configure
make
sudo make install
Step 5: Install oTcl
Important Note: The ‘./configure –with-tcl=’ portion of the following two code fragments should point to the source files for tcl. If you have been following the guide by copying and pasting the previous commands what we have here will work just fine. Otherwise you will need to change this to point to the correct location of your tcl source files.
cd ..
cd ..
wget http://www.jasonernst.com/wp-content/uploads/2008/06/otcl-src-1.13.tar.gz
tar xvf otcl-src-1.13.tar.gz
cd otcl-1.13
./configure --with-tcl=../tcl*/
make
sudo make install
Step 6: Install tclcl
cd ..
wget http://www.jasonernst.com/wp-content/uploads/2008/06/tclcl-src-1.19.tar.gz
tar xvf tclcl-src-1.19.tar.gz
cd tclcl-1.19
./configure --with-tcl=../tcl*/
make
sudo make installStep 7: Install ns2
cd ..
wget http://www.jasonernst.com/wp-content/uploads/2008/06/ns-2.33.tar.gz
tar xvf ns-2.33.tar.gz
cd ns-2.33
./configure
make
sudo make install
You will likely get alot of warnings for deprecated conversions. Just ignore these or if you really are concerned about them visit the nsnam troubleshooting page. If you want to make sure your version of ns-2 is working correctly after the install you can run the validation test from within the ns2 source directory. You can do this by entering:
./validate
You should see that the test output agrees with the reference output. Congratulations you have a working version of ns-2 installed.
Step 8: (optional) Install nam
cd ..
wget http://www.jasonernst.com/wp-content/uploads/2008/06/nam-src-1.13.tar.gz
tar xvf nam-src-1.13.tar.gz
cd nam-1.13
./configure
make
sudo make install
Note: if you get this error:
error: X11/Xmu/WinUtil.h: No such file or directoryit may be necesary to do this:
sudo apt-get install libxmu-devYou are now ready to start working with ns2 and nam. If you are like me and working on a new protocol or something you will want to start modifying the ns-2 source code and recompile again so you might want to keep that folder handy. The rest of the source can be safely removed as far as i know. Keep in mind after you have modified the source you will want to do another make install so that when you type ns in your terminal the version you just compiled is used.
Getting Started with NS2
These are some quick tips to get you started using ns2 if you are a beginner.
All example files are located in ns/tcl/ex. You can run these scenarios on ns2 using ns filename.tcl The best way to start is probably changing things in these files until you understand what is happening more thoroughly.
The output will usually be a trace file with a similar name: ex) filename.tr. Trace files can usually be viewed with a text-editor program. There are also tools to analyze the trace files and pull stats from them. These may require some tweaking however depending on the format of the trace file. Additionally, a nam output file for visualization may be generated as well. This will usually be named filename.nam. To view the visualization use: nam filename.nam
Useful Links
I thought it might be useful to add a section on useful links here since this article has become quite popular. If you would like to suggest a link feel free to contact me.
- Ns2 Wiki
- Marc Greis’ Tutorial
- NS Manual
- NS for Beginners (pdf)
- Common NS2 Installation Problems
- NS2 Wireless and Mobility Modules
- NS2 Mailing Lists
- NS2.33 Wireless MAC and PHY improvements
Previous: « Fair Scheduling & Load Balancing in WMN
103 Responses to Tutorial: Ns-2.33 (and nam) on Ubuntu 8.04 (Hardy Heron)
Leave a Reply
Leave a Reply
Recent Articles
Creating a Bluetooth Access point (NAP) in Ubuntu 11.10
November 29, 2011
A Bluetooth NAP is similar to a Wi-Fi access point. In this case, we will...
Burg / Grub 2 Icons for Meego
November 29, 2011
Only recently I noticed that Moblin (which I sometimes use) has changed...
Aircrack suite + Ubuntu 11.10 problems with monitor mode...
November 4, 2011
Recently I have been playing around with the aircrack suite and in...
Upcoming PhD QE Progress
July 27, 2011
So I've been doing my PhD for over two years now, and I haven't posted a...
Why Blanket Wireless Coverage in Waterloo Failed, and...
July 22, 2011
Today the KW Record ran an article entitled "Blanket Wi-Fi plans unplugged...
Windows 7 – SP1, Multiple OS – Grub
July 17, 2011
A while ago I bought a Toshiba netbook which of course came with Windows 7...








June 11, 2008

Categories:
Tags: 










Sitemap
Valid XHTML
Valid CSS
Login
Hi!Jason
Thanks your reply.
Still I have problem with LEACH implementation. I spend too much time for it, becuase it will very necessary to me. My installing detials following:
1. I installed both Cygwin on Windows and Fedora5
2. tar zxvf ns-allinone-2.27.tar.gz
patch -p0 < ns-227-gcc34.patch
cd ns-allinone-2.27/
./install
3. Exract mit.tar.gz in ns-allinone-2.27/ns-2.27
4. In ns-allinone-2.27/ns-2.27, patch -p0 < leach_makefile-2.27.patch
5. Edit the Makefile as a follows in
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 \
4. Added to .basch file
Hi!Jason
Thanks your reply.
Still I have problem with LEACH implementation. I spend too much time for it, becuase it will very necessary to me. My installing detials following:
1. I installed both Cygwin on Windows and Fedora5
2. tar zxvf ns-allinone-2.27.tar.gz
patch -p0 < ns-227-gcc34.patch
cd ns-allinone-2.27/
./install
3. Exract mit.tar.gz in ns-allinone-2.27/ns-2.27
4. In ns-allinone-2.27/ns-2.27, patch -p0 < leach_makefile-2.27.patch
5. Edit the Makefile as a follows in
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 \
6. Modified source code: ~/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))
7. Added to . bashrc file:
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:$NS_HOME/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=$NS_HOME/tcl8.4.5/library
export RCA_LIBRARY=`pwd`/ns-allinone-2.27/ns-2.27/mit/rca
export uAMPS_LIBRARY=`pwd`/ns-allinone-2.27/ns-2.27/mit/uAMPS
8. make clean
9. make
But make command has following error:
In file included from tools / random.cc: 40:
config.h:60:19: tclcl.h: No such file or directory config.h: 60:19: tclcl.h: No such file or directory
In file included from tools/random.h:42, In file included from tools / random.h: 42,
from tools/random.cc:41: from tools / random.cc: 41:
tools/rng.h:103: error: syntax error before ‘<’ token tools / rng.h: 103: error: syntax error before ‘<’ token
tools/rng.h:112: error: syntax error before ‘const’ tools / rng.h: 112: error: syntax error before ‘const’
tools/rng.h:113: error: syntax error before ‘long’ tools / rng.h: 113: error: syntax error before ‘long’
tools/rng.h:121: error: syntax error before ‘,’ token tools / rng.h: 121: error: syntax error before ‘,’ token
When running tcl/ex/wireless.tcl following error:
couldn’t read file “tcl / lib / ns-mobilenode.tcl”: no such file or directory
(procedure “source” line 
while executing while executing
“source.orig tcl/lib/ns-mobilenode.tcl” “source.orig tcl / lib / ns-mobilenode.tcl”
(“uplevel” body line 1) ( “uplevel” body line 1)
invoked from within invoked from within
“uplevel source.orig [list $fileName]” “uplevel source.orig [list $ fileName]”
invoked from within invoked from within
“if [$instance_ is_http_url $fileName] { “if [$ instance_ is_http_url $ fileName] (
set buffer [$instance_ read_url $fileName] set buffer [$ instance_ read_url $ fileName]
uplevel eval $buffer uplevel eval $ buffer
} else { ) Else (
uplevel source.orig [list $fileName] uplevel source.orig [list $ fileName]
…” … ”
(procedure “source” line
invoked from within invoked from within
“source tcl/lib/ns-mobilenode.tcl” “source tcl / lib / ns-mobilenode.tcl”
(file “wireless.tcl” line 184) (file “wireless.tcl” line 184)
I don’t have any idea to continue do my work. Which step i have a mistake?
Please help me! I will be very appreciate your reply.
Sincerely. Oogii
You may need to locate the files that it cannot find yourself and change the wireless.tcl script such that it points to the correct location of these scripts. They are probably not in the correct location, but still around somewhere in the directory structure.
hello
thank you all for the help..
but i have a big problem with nam…..
can anyone tell me how to solve it…..?
Hi dear Jason thank u very much for ur efforts
I managed to install ns2.33 on ubuntu. can u plz tell me if I need any patch to work on infrastructure mode (access point) in ns2.33 or it can support this mode without any patch?
thanks again
Mary
Hi,
I created new protocol which is basically extension od AODV protocol.
I changed evry thing, and i complied my code it compiled perfectly. but when i run a tcl script against my protocol, it shows message as “Wrong node routing Agent!”. Kindly clarify this and please provide some information on how to add new protocol to ns-2.27.
Thanks!!!
hi,
i have followed the steps but i get an error when i do: make in ns2.33 installation. it appears:
…..
/main-monolithic.o -L/home/bea/tclcl-1.19 -ltclcl -L/home/bea/otcl-1.13 -lotcl -L/usr/local/lib -ltk8.4 -L/usr/local/lib -ltcl8.4 -lXext -lX11 -lnsl -lpcap -ldl -lm -lm
/usr/bin/ld: ns: hidden symbol `__stack_chk_fail_local’ in /usr/lib/libc_nonshared.a(stack_chk_fail_local.oS) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld devolvió el estado de salida 1
make: *** [ns] Error 1
what can i do? please some help!!!
thank you in advance
Hi Bea, please see earlier comments in this post on the same problem you are having: http://www.jasonernst.com/2008/06/11/ns-233-and-nam-on-ubuntu-804-hardy-heron/comment-page-1/#comment-628 and http://www.jasonernst.com/2008/06/11/ns-233-and-nam-on-ubuntu-804-hardy-heron/comment-page-1/#comment-629
Hi Jason
Thank you very much for this manual!
I followed all steps and also steps from ns-nam troubleshooting.
I get an error while launching nam:
nam:
[code omitted because of length]
: no event type or button # or keysym
while executing
"bind Listbox {
%W yview scroll [expr {- (%D / 120) * 4}] units
}"
invoked from within
"if {[tk windowingsystem] eq "classic" || [tk windowingsystem] eq "aqua"} {
bind Listbox {
%W yview scroll [expr {- (%D)}] units
}
bind Li..."
Could you please help.
Hi, You said you are likely to post some work on power control, how soon is this?
Hi Dan, it turns out my research has taken a bit of a change of direction. I haven’t done much work with power control yet, however I am working with a cross-layer scheduling algorithm. There may be an opportunity to work power control into this, although I have no plans for it yet. I will post code of what I am working on after I defend my thesis (ns3 code)