Blog
NS2 Installation Guide: Step-by-Step Setup on Linux

Network Simulator 2 (NS2) is a widely used tool for simulating network protocols, routing algorithms, and wireless networks. It is primarily used in research and academic projects related to networking. Installing NS2 requires some dependencies and configuration, especially on Linux-based systems like Ubuntu. In this guide, we will go through a step-by-step installation process of NS2 on a Linux system (Ubuntu) and verify the installation.
Step 1: Update the System
Before installing NS2, update the system to ensure all packages are up to date. Open a terminal and run:
bash
CopyEdit
sudo apt update && sudo apt upgrade -y
Step 2: Install Required Dependencies
NS2 requires several dependencies, such as Tcl, Tk, Perl, and GCC. Install them using the following command:
bash
CopyEdit
sudo apt install -y build-essential tcl tk tcl-dev tk-dev perl libxmu-dev xgraph
Step 3: Download NS2 Package
Download the latest stable version of NS2 (e.g., ns-2.35) from the official website or use the following command:
bash
CopyEdit
wget https://www.isi.edu/nsnam/dist/ns-allinone-2.35.tar.gz
Step 4: Extract the NS2 Package
Extract the downloaded tar file using:
bash
CopyEdit
tar -xvzf ns-allinone-2.35.tar.gz
cd ns-allinone-2.35
Step 5: Compile and Install NS2
Run the installation script to compile NS2 and all its components:
bash
CopyEdit
./install
This process may take several minutes. If there are any errors, ensure that all dependencies are installed.
Step 6: Configure Environment Variables
After installation, you need to set up environment variables to run NS2 from any directory. Open the bashrc file:
bash
CopyEdit
nano ~/.bashrc
Add the following lines at the end of the file:
bash
CopyEdit
export NS_HOME=$HOME/ns-allinone-2.35
export PATH=$NS_HOME/bin:$NS_HOME/tcl8.5.10/unix:$NS_HOME/tk8.5.10/unix:$PATH
export LD_LIBRARY_PATH=$NS_HOME/otcl-1.14:$NS_HOME/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=$NS_HOME/tcl8.5.10/library
Save the file and apply the changes:
bash
CopyEdit
source ~/.bashrc
Step 7: Verify NS2 Installation
Check if NS2 is correctly installed by running:
bash
CopyEdit
ns
If NS2 is installed correctly, you will see the % prompt, indicating that NS2 is ready to use.
Step 8: Run a Simple NS2 Simulation

Create a simple simulation script in a text file:
bash
CopyEdit
nano simple.tcl
Paste the following Tcl script:
tcl
CopyEdit
# Create a simulator instance
set ns [new Simulator]
# Define network nodes
set n1 [$ns node]
set n2 [$ns node]
# Create a link between nodes
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
# Define simulation end
$ns at 5.0 “finish”
proc finish {} {
global ns
$ns halt
}
# Run the simulation
$ns run
Save and exit. Run the script using:
bash
CopyEdit
ns simple.tcl
If NS2 runs without errors, the installation is successful!
Conclusion
Installing NS2 on Linux requires a few dependencies, proper configuration, and environment variable setup. By following these step-by-step instructions, you can successfully install and test NS2 for network simulation experiments.
Tech2 years agoHow to Use a Temporary Number for WhatsApp
Business3 years agoSepatuindonesia.com | Best Online Store in Indonesia
Social Media2 years agoThe Best Methods to Download TikTok Videos Using SnapTik
Technology2 years agoTop High Paying Affiliate Programs
Tech1 year agoUnderstanding thejavasea.me Leaks Aio-TLP: A Comprehensive Guide
FOOD2 years agoHow to Identify Pure Desi Ghee? Ultimate Guidelines for Purchasing Authentic Ghee Online
Instagram4 years agoFree Instagram Auto Follower Without Login
Instagram4 years agoFree Instagram Follower Without Login















