How to Install NS-3 on Ubuntu 20.04 LTS

There are multiple ways to install NS-3 on Linux OS. You can Google it to find those. Personally I prefer to collect the necessary commands and then create a bash script to be used in future. Before sharing the bash script I am going to explain the necessary steps that you may consider trying.

Installation Steps

Make sure that you are on the Home Directory

cd ~

Update the Ubuntu Repo and Existing Applications

sudo apt update

sudo apt -y upgrade

Install Core Dependencies for Build and Compilation

sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml

Install Dependencies for NS-3 Python bindings

sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml

Install Dependencies for NS-3

sudo apt install g++ pkg-config sqlite3 qt5-default mercurial ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gdb valgrind uncrustify doxygen graphviz imagemagick python3-sphinx dia tcpdump libxml2 libxml2-dev cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake

Install Additional Python Packages

sudo su 
cd
pip3 install kiwi
exit
cd

Download and Install NS-3 and NetAnim

# download from ns-3 server
wget -c https://www.nsnam.org/releases/ns-allinone-3.33.tar.bz2
# extract tar.bz2
tar -xvjf ns-allinone-3.33.tar.bz2
# go back to home folder
cd

# navigate to ns-3 directory (not the NS-3 all in one)
cd ns-allinone-3.33/ns-3.33/
# Configure the installation
./waf configure --enable-examples 
# Build ns-3 installation
./waf
# to check whether installation was a success
./waf --run hello-simulator

# navigate to netanim dir.
cd ns-allinone-3.33/netanim-3.108/
# configure the build
make clean
# compile the build
qmake NetAnim.pro
# build netanim installation
make
# to execute NetAnim 
./NetAnim

I hope this will help you. I am not an expert, but this is a sharing of the experience I’ve gained over the past few years. Feel free to ask questions in the comments and/or fill in any points that I haven’t explained well or that are missing.

Md Monjurul Karim
Md Monjurul Karim
Research and Teaching Assistant

My research interests span on Machine Learning, Edge Computing, and Distributed Computer Networking.