Step 1: update the system. Enter the following command on the terminal:
Sudo app-get update # update source list
Sudo app-get upgrade # Update installed packages
Sudo app-get dist-upgrade # update software and upgrade the system
Step 2: install several required packages
Sudo apt-get install build-essential
Sudo apt-get install tcl8.5 tcl8.5-dev tk8.5 tk8.5-dev # for tcl and tk
Sudo apt-get install libxmu-dev libxmu-headers # for nam
Step 3: Download the installation package and copy it to the directory to be installed. You must obtain the root permission to install the package.
Official Website: http://www.isi.edu/nsnam/ns/, download allinone
Tar xvfz ns-allinone-2.35.tar.gz
Cd ns-allinone-2.35
./Install # install
Step 4: Configure Environment Variables
Edit the. bashrc file in the current user directory.
Vim. bashrc
Add
# Add path for NS2.
Export PATH = "$ PATH:/home/liushun/ns-allinone-2.35/bin:/home/installation folder name/ns-allinone-2.35/tcl8.5.10/unix: /home/installation folder name/ns-allinone-2.35/tk8.5.10/unix"
Export LD_LIBRARY_PATH = "$ LD_LIBRARY_PATH:/home/installation folder name/ns-allinone-2.35/otcl-1.14:/home/installation folder name/ns-allinone-2.35/lib"
Export TCL_LIBRARY = "$ TCL_LIBRARY:/home/installation folder name/ns-allinone-2.35/tcl8.5.10/library"
Step 5: Verify Installation
Log on to the console and enter ns. Then, the system prompts you to install NS2. enter
Sudo apt-get install NS2.
Enter ns again. "%" is displayed, indicating that the installation is successful.
Enter nam and an error is reported. The system prompts you to install nam and enter it as prompted.
Sudo apt-get install nam
If the preceding command is invalid, enter
Sudo apt-get update # update