I think it might be worth writing a blog post on
ns2 installation. As we know, ns2 is a network simulator used a lot by students and researchers in the field of networking. I, personally, had not touched the simulator since I graduated in 2006!! However, today I thought I would install it on my Ubuntu-run laptop and revisit my knowledge. Well, actually the real reason for installing it was because I had an idea on a research on
remote procedure call (RPC) and its performance and security.
I remember that installing ns2 back in 2002 was not an easy task. Lots of compilations and finding dependencies were to be carried out. That was over ten years ago. With today's technologies and operating system, it cannot be as hard surely. Or can it?
My laptop is now running
Ubuntu 12.04 LTS, which is the latest version. I was thinking about what packages to install and how to install them with the least effort and, of course, the fewest number of errors possible.
Yes! Ubuntu comes with the
Ubuntu Software Centre. What I did was I searched for ns2. Bam! It showed. I clicked on the install button. All done!
I could not believe how simple it was.
I then tried out a few simple scripts, running a few simple network scenarios, and sending a few packets. Everything worked. The graphical simulator worked.
Even though everything seemed fine, there was one more thing for me to test in order to believe that ns2 worked perfectly.
I wrote a simple protocol. As I remembered, that means I had to create a .h file and a .cc file. I would then have to edit the ns2's packet.h file, ns-default.tcl file and several others. It sounded easy in my head. What's so hard about writing my own files and editting the ns2's existing files?
No!! Where are all the ns2's files!!??? That's right. I could not find them anywhere in the system. I tried the locate command. I tried looking for them in all the directories. They weren't there!!
THIS is a big problem for me now. I, therefore, concluded that installing ns2 using the Ubuntu Software Centre was very easy and everything worked. However, when I wanted to do something a little bit more advanced, I could not do it.
Damn! My only option at that moment was to remove the ns2 from my system entirely. Of course, via the Ubuntu Software Centre. Again, very easy.
I now had to do what I wanted to avoid in the first place. Installing from the source. Fortunately, thanks to several Web pages that provided me with very simple guides on how to get ns2 to work without the help of the Ubuntu Software Centre.
Here are the steps to be followed when installing ns2 on Ubuntu:
1. Download the ns2 all-in-one source file from here.
2. Install all necessary dependencies using this command:
sudo apt-get install build-essential autoconf automake libxmu-dev
3. Update the package list from the repository using this command:
sudo apt-get update
4. Unpack the file that you have downloaded in Step 1:
tar -zxvf ns-allinone-2.35.tar.gz
5. Run the following commands:
cd ns-allinone-2.35/
./install
6. Once it has finished installing, edit the .bashrc file by adding:
PATH=~/ns-allinone-2.35/bin:/home/sirapat/ns-allinone-2.35/tcl8.5.10/unix:~/ns-allinone-2.35/tk8.5.10/unix
export LD_LIBRARY_PATH=~/ns-allinone-2.35/otcl-1.14:~/ns-allinone-2.35/lib
export TCL_LIBRARY=~/ns-allinone-2.35/tcl8.5.10/library
7. In the ns-2.35 directory, run:
./validate
This should complete the ns2 installation.
The network simulator should work as it is now. However, with more complicated scenarios where you want to create your own protocols, ns2 may ask for pcap.h and pcap.cc files. In this case, the following command must be run in order to incall the pcap library.
sudo apt-get install libpcap-dev
That's it. That was really all I did, and I was able to get ns2 working perfectly.
It was a lot simpler than what I had to go through ten years ago. ^_^