steps to install ns2

STEPS TO INSTALL NS2 ON UBUNTU 16.04

Posted by

STEPS TO INSTALL NS2

NS2 is an open-source simulation tool that runs on Linux. It is a discreet event simulator targeted at networking research and provides substantial support for simulation of routing, multicast protocols and IP protocols, such as UDP, TCP, RTP and SRM over wired and wireless (local and satellite) networks.


  • Download NS2 (NS- 2.35) from this link
    it get downloaded into your ‘/home/your_user_name/Downloads’ directory.
  • copy it to /opt folder by following command
    cp /home/user_name/Downloads/ns-allinone-2.35.tar.gz /opt/
  • Install Prerequisites
    Type following commands on terminal
  1. sudo apt-get update
  2. sudo apt-get dist-upgrade
  3. sudo apt-get update
  4. sudo apt-get gcc
  5. sudo apt-get install build-essential autoconf automake
  6. sudo apt-get install tcl8.5-dev tk8.5-dev
  7. sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev
  • Extract ns2
    Type following commands on terminal
  1. tar -zxvf ns-allinone-2.35.tar.gz
  2. cd ns-allinone-2.35
  3. ./install
  • Open bashrc file to Set the Environment Variables
    Type following commands on terminal
  1. sudo gedit ~/.bashrc
  • Copy the following lines AT THE END of the file.
    # LD_LIBRARY_PATH
    OTCL_LIB=/opt/ns-allinone-2.35/otcl-1.14/
    NS2_LIB=/opt/ns-allinone-2.35/lib/
    USR_Local_LIB=/usr/local/lib/
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_Local_LIB

# TCL_LIBRARY
TCL_LIB=/opt/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB

# PATH
XGRAPH=/opt/ns-allinone-2.35/xgraph-12.2/:/opt/ns-allinone-2.35/bin/:/opt/ns-allinone-2.35/tcl8.5.10/unix/:/opt/ns-allinone-2.35/tk8.5.10/unix/
NS=/opt/ns-allinone-2.35/ns-2.35/
NAM=/opt/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM
#—-

  • Type following commands on terminal
  1. source ~/.bashrc
  • Type following commands on terminal
  1. ns

If you received the “%” sign, it means that NS is running correctly !


Steps to uninstall ns2

  1. Delete the directory ‘ns-allinone-2.35’.
  2. Delete the ns related files from ‘/user/local/bin’.
  3. Edit the ‘.bashrc file’ and remove the paths that you have added during the installation.
  4. Restart the system and run following commands one by one:
  5. sudo apt-get autoremove
  6. sudo apt-get clean