Installing ns3 in Ubuntu 22.
04
------------------------------
Step 1: Prerequisites (Installing and updating necessary
packages)
-------------------------------------------------------------
1) sudo apt update
2) sudo apt install g++ python3 python3-dev pkg-config sqlite3
cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake
qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-
cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin
openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr
unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite
sqlite3 libsqlite3-dev libxml2 libxml2-dev libc6-dev libc6-
dev-i386 libclang-dev llvm-dev automake python3-pip libxml2
libxml2-dev libboost-all-dev
----------------------------------------------------------------------
Step 2: Download ns-allinone-3.40.tar.bz2 from the website
https://www.nsnam.org/releases/ns-allinone-3.36.1.tar.bz2
----------------------------------------------------------------------
Step 3: Unzip and Install the tarball
-------------------------------------
1) tar jxvf ns-allinone-3.40.tar.bz2
2) cd ns-allinone-3.40/
3) ./build.py --enable-examples --enable-tests
-----------------------------------------------
Step 4: Running a Sample Script
------------------------------
1) ./ns3 run hello-simulator
(You will get the output as) Hello Simulator
Step 5: Saving and running a ns3 script
---------------------------------------
1) Save the written script inside ns-3.40/scratch directory
2) To run the written script, execute the following command
(for .cc file - C++ file)
./ns3 run scratch/first
(for python file)
./ns3 run scratch/first.py