When I first started ns-3 (Network Simulator 3), I was in an ocean of bafflements. It took me several days to install ns-3 on Ubuntu for the first time, although I am an Ubuntu user. There is nothing wrong with Ubuntu, it is user friendly and cool as always. The main problem is the installation process of ns-3, which is, in true sense is not user friendly (at all). From my experience, I understand that it can be overwhelming for people using either ns-3 or Ubuntu or both for the first time. So this is a newbie guide to install and configure ns-3 on Ubuntu for the first time.
Step 1: Prepare the prerequisites
- First, I assume that you are running Ubuntu 16.04 operating system the latest LTS version of Ubuntu. But the process should work on other Ubuntu distributions as well.
- Second, I assume that you are using Ubuntu either Natively or using a Virtual Machine (VM) (a VM is strongly recommended if you don’t know what you are doing).
- Third, I assume that you have a working Internet connection on Ubuntu at the time of installation.
If you are done with the above three tasks, then we are clear to proceed. Now we will install the required packages and libraries before downloading and installing ns-3. To do this go to the Dash (the big Ubuntu logo on the top of the launcher) and search for Software & Updates like the following picture.
Click the the Software & Updates icon from the above picture (marked with a yellow circle). The following window will be opened. Check everything under Ubuntu Software. You may be asked enter your password in order to effect a change.
Check everything under Other Software.
Check everything under Updates.
Click on Close button from the bottom. Now click the Reload button when you are asked to confirm reloading the repository cache.
Now open a Terminal by searching for it in the Ubuntu Launcher. Run the following commands in the Terminal:
First update and upgrade your system just to be sure.
sudo apt-get update && sudo apt-get -y upgrade
Now install the following development libraries and dependencies by using the command below:
sudo apt-get -y install gcc g++ python python-dev qt4-dev-tools mercurial bzr cmake libc6-dev libc6-dev-i386 g++-multilib gdb valgrind gsl-bin libgsl-dev libgsl2 flex bison libfl-dev tcpdump sqlite sqlite3 libsqlite3-dev libxml2 libxml2-dev libgtk2.0-0 libgtk2.0-dev uncrustify python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev
Now, install Wireshark if you prefer a Graphical Protocol Analyzer to work with the .pcap files instead of the tcpdump (CLI tool).
sudo apt-get -y install wireshark
You can also install the Gnuplot plotting engine as ns3 has in-built support for generating graphs using Gnuplot. Gnuplot also has a graphical front-end interface called PlotDrop that may be useful for beginners for creating plots/graphs using a simple drag-and-drop interface. To install both the packages use:
sudo apt-get -y install gnuplot plotdrop
Step 2: Install ns-3 Stable Branch
In this section, we’ll install the ns-3 stable release available at ns-3 Releases. At the time of this writing, the latest available stable release of ns-3 is ns-3.25. The stable release should serve the needs of most users and is the recommended install option.
For downloading and installing the ns-3 stable we will create a new directory named Softwares under the Home directory. You can create any directory as you wish. (Creating the directory is not mandatory, it just helps you to organize your applications). Create the new Softwares directory by the following commands (execute one line at a time):
cd ~
mkdir Softwares
Now, we will download the compressed ns-3.25 file and extract it inside the Softwares directory by the following commands (execute one line at a time):
cd Softwares
wget http://www.nsnam.org/release/ns-allinone-3.25.tar.bz2
tar xvjf ns-allinone-3.25.tar.bz2
Now we will enter inside the ns-allinone-3.25 directory by the following command:
cd ns-allinone-3.25
Using the following command we will see the directory structure :
ls
If everything is going perfect till now, you should see the following directory structure on the terminal:
bake constants.py ns-3.25 README
build.py netanim-3.107 pybindgen-0.17.0.post49+ng0e4e3bc util.py
Now all you need is to build ns-3 using the following command:
./build.py --enable-examples --enable-tests
The above build script takes lot of times to be completed and outputs lot of information on the terminal and eventually you should see the build finished successfully message as shown below.
Step 3: The wrap-up
You can now use the waf tool to build your simulation scripts. If you installed the 3.25 release version, execute the following command (execute one line at a time):
cd ns-3.25
./waf --run scratch/scratch-simulator
If you are still following this tutorial, then Congratulation! Now you have successfully installed ns-3 in your Ubuntu. You have a working ns3 installation and you can start it right now.
Disclaimer: This tutorial is designed for an Ubuntu 16.04 distribution but should work in other distribution as well. |
ns-2 installation was easy 😒
Well… try the following single line command and it will be hassle-free! 😛
very helpfull, thanks