Pages

Search This Blog

Tuesday, 18 October 2011

Installing ns-2.34 on Ubuntu 11.04

NS2 is a popular discrete event simulator for simulating different types of networks. In this article i will show you how to install NS-2.34 on Ubuntu 11.04.  

Note: Please connect your pc to internet, it is very important because failure of connection may cause some error in installing ns2 or in some future work.

  • Download ns2.34 from here. 
  • Copy ns-allinone-withpath-2.34.tbz to /tmp directory.
  • Copy it to the /usr/local directory using terminal by using following command
       sudo cp /tmp/ns-allinone-withpath-2.34.tbz /usr/local/     
  • Change directory to /usr/local
       cd /usr/local/
  • Extract it using the following command
       sudo tar -jxvf ns-allinone-withpath-2.34.tbz 
  • Change directory to ns-allinone-2.34
       cd ns-allinone-2.34/
  • Now, install the development files for X Windows plus the g++ compiler:
       sudo apt-get install xorg-dev g++ xgraph
  • Fix the error in the linking of otcl by editing line 6304 of otcl-1.13/configure so that it reads                    
        SHLIB_LD="gcc -shared"
        instead of
        SHLIB_LD="ld -shared"

  • Then, edit the file ns-2.34/tools/ranvar.cc and change the line 219 from
        return GammaRandomVariable::GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);
        to
        return GammaRandomVariable(1.0 + alpha_, beta_).value() * pow (u, 1.0 / alpha_);

  • Next, change the lines 183 and 185 in file ns-2.34/mobile/nakagami.cc to read
        resultPower = ErlangRandomVariable(Pr/m, int_m).value();
        and
        resultPower = GammaRandomVariable(m, Pr/m).value(); 

  • Install gcc-4.4 and g++-4.4 including dependencies using the code below:
        $ sudo apt-get install gcc-4.4 g++-4.4 
              If there is any occur while installing these than you can use 
        sudo synaptic
        here you can search it and easily download and install it. 
  • Now, change the line 270 in tcl8.4.18/unix/Makefile.in that reads
        CC = @CC@
        so it appends the version parameter for version 4.4:
        CC = @CC@ -V 4.4
         Make sure it is a capital V.

  • Finally,run the command
         sudo ./install
  • After installation type the following command in a terminal
          source /etc/profile.d/ns2.sh
Now ns-2.34 is installed on ubuntu 11.04, you can check it by typing "ns" on terminal and press enter.