NS-3
License
- GNU GPL Version 2.0
Installation on Linux/Ubuntu (Version NS-3.42)
https://www.nsnam.org/wiki/Installation
https://www.nsnam.org/docs/installation/singlehtml/
https://www.nsnam.org/docs/tutorial/html/getting-started.html
https://www.nsnam.org/docs/release/3.42/installation/html/
Prerequisites
## Minimal Requirement sudo apt install g++ python3 cmake ninja-build git
## Recommended for Compiler Cache Optimization sudo apt install ccache
Optional Components
## Python Visualizer and Bindings python3 -m pip install --user cppyy #python3 -m pip install --user cppyy==2.4.2 sudo apt install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3
## Python Development sudo apt install python3-setuptools git
## Netanim Animator sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools sudo apt install qt5-default
## PyViz Visualizer sudo apt install gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3
## MPI-Based Distributed Emulation sudo apt install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev
## Bake Build Tool sudo apt install mercurial unzip
## Debugging sudo apt install gdb valgrind
## Code Style Check sudo apt install clang-format
## Inline Documentation #sudo apt install doxygen graphviz imagemagick #sudo apt install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk
## Manual and Tutorial #sudo apt install python3-sphinx dia
## GNU Scientific Library (GSL) for 802.11b WiFi Error Models sudo apt install gsl-bin libgsl-dev libgslcblas0
## PCAP Packet Traces sudo apt install tcpdump
## Statistics Framework sudo apt install sqlite sqlite3 libsqlite3-dev
## Config Store sudo apt install libxml2 libxml2-dev
## GTK-Based Configuration System sudo apt install libgtk-3-dev
## Experiment with Virtual Machines sudo apt install vtun lxc uml-utilities
## Openflow Module and Boost Development Libraries sudo apt install libxml2 libxml2-dev libboost-all-dev
Installation with Bake
mkdir NS-3 cd NS-3
git clone https://gitlab.com/nsnam/bake
export BAKE_HOME=`pwd`/bake export PATH=$PATH:$BAKE_HOME export PYTHONPATH=$PYTHONPATH:$BAKE_HOME
bake.py check #bake.py configure -e ns-3.42 bake.py configure -e ns-allinone-3.42 bake.py show
## -- System Dependencies -- ## > automake - OK ## > cmake - OK ## > cppyy - OK ## > g++ - OK ## > gi-cairo - OK ## > gir-bindings - OK ## > libxml2-dev - OK ## > mercurial - OK ## > pygobject - OK ## > pygraphviz - OK ## > python3-dev - OK ## > qt - OK
bake.py deploy #bake.py download #bake.py build
## Downloading, building and installing the selected modules and dependencies. ## Please, be patient, this may take a while! ## >> Searching for system dependency libxml2-dev - OK ## >> Downloading click-ns-3.37 - OK ## >> Searching for system dependency g++ - OK ## >> Searching for system dependency cppyy - OK ## >> Searching for system dependency gi-cairo - OK ## >> Searching for system dependency gir-bindings - OK ## >> Searching for system dependency pygobject - OK ## >> Searching for system dependency pygraphviz - OK ## >> Searching for system dependency python3-dev - OK ## >> Searching for system dependency qt - OK ## >> Searching for system dependency cmake - OK ## >> Searching for system dependency mercurial - OK ## >> Searching for system dependency automake - OK ## >> Downloading openflow-dev - OK ## >> Downloading netanim-3.109 - OK ## >> Downloading BRITE - OK ## >> Downloading ns-3.42 (target directory:ns-3.42) - OK ## >> Building click-ns-3.37 - OK ## >> Building openflow-dev - OK ## >> Building netanim-3.109 - OK ## >> Building BRITE - OK ## >> Building ns-3.42 - OK
Building with NS-3 CMake Wrapper
cd source/ns-3.42
./ns3 show
## Build profile: default ## ns-3 version: ns-3.42 ## Reconfigure with './ns3 configure --enable-build-version' to bake the version into the libraries. ## ---- Summary of ns-3 settings: ## Build profile : default ## Build directory : /home/dai/source/ns-3.42/build ## Build with runtime asserts : ON ## Build with runtime logging : ON ## Build version embedding : OFF (not requested) ## BRITE Integration : ON ## DES Metrics event collection : OFF (not requested) ## DPDK NetDevice : OFF (not requested) ## Emulation FdNetDevice : ON ## Examples : ON ## File descriptor NetDevice : ON ## GNU Scientific Library (GSL) : ON ## GtkConfigStore : ON ## LibXml2 support : ON ## MPI Support : OFF (not requested) ## ns-3 Click Integration : ON ## ns-3 OpenFlow Integration : ON ## Netmap emulation FdNetDevice : OFF (missing dependency) ## PyViz visualizer : OFF (missing Python Bindings) ## Python Bindings : OFF (missing dependency: cppyy) ## SQLite support : ON ## Eigen3 support : OFF (Eigen was not found) ## Tap Bridge : ON ## Tap FdNetDevice : ON ## Tests : ON ## ## Modules configured to be built: ## antenna aodv applications ## bridge brite buildings ## click config-store core ## csma csma-layout dsdv ## dsr energy fd-net-device ## flow-monitor internet internet-apps ## lr-wpan lte mesh ## mobility netanim network ## nix-vector-routing olsr openflow ## point-to-point point-to-point-layout propagation ## sixlowpan spectrum stats ## tap-bridge test topology-read ## traffic-control uan virtual-net-device ## wifi wimax ## ## Modules that cannot be built: ## mpi visualizer ## ## ---- Summary of buildable targets: ## Buildable targets: 80 ## Runnable/Buildable targets: 294
#./ns3 configure --enable-examples --enable-tests ./ns3 configure --enable-examples --enable-tests --enable-python-bindings ./ns3 build
Troubleshooting - Cppyy Missing Dependency
## -- Bindings: python bindings disabled due to the following missing dependencies: cppyy
To be investigated; using pip and netanim would be alternatives.
Troubleshooting - Bindings Install Directory
## -- NS3_BINDINGS_INSTALL_DIR was not set. The python bindings won't be installed with ./ns3 install. This setting is meant for packaging and redistribution. ## -- Set NS3_BINDINGS_INSTALL_DIR="/home/user/.local/lib/python3.8/site-packages" to install it to the default location.
To be investigated; just ignoring this warning for the moment.
Python Bindings
https://www.nsnam.org/docs/manual/html/python.html
pip install --user ns3
Troubleshooting - No Matching Distribution
## ERROR: Could not find a version that satisfies the requirement ns3 (from versions: none) ## ERROR: No matching distribution found for ns3
pip install --upgrade setuptools
Test
./test.py
## [ 0%] Building CXX object src/antenna/CMakeFiles/libantenna-obj.dir/model/circular-aperture-antenna-model.cc.o ## [ 0%] Building CXX object src/antenna/CMakeFiles/libantenna-obj.dir/model/angles.cc.o ## [ 0%] Building CXX object src/antenna/CMakeFiles/libantenna-obj.dir/model/antenna-model.cc.o ## [ 0%] Building CXX object src/antenna/CMakeFiles/libantenna-obj.dir/model/cosine-antenna-model.cc.o ## [ 0%] Building CXX object src/antenna/CMakeFiles/libantenna-obj.dir/model/isotropic-antenna-model.cc.o ## ... ## [773/780] PASS: Example src/buildings/examples/buildings-pathloss-profiler ## [774/780] PASS: Example src/buildings/examples/outdoor-group-mobility-example --useHelper=0 ## [775/780] PASS: Example src/buildings/examples/outdoor-group-mobility-example --useHelper=1 ## [776/780] PASS: Example src/brite/examples/brite-generic-example ## [777/780] PASS: Example src/bridge/examples/csma-bridge ## [778/780] PASS: Example src/bridge/examples/csma-bridge-one-hop ## [779/780] PASS: Example src/aodv/examples/aodv ## 780 of 780 tests passed (780 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)
Tutorials
Hello Simulator
./ns3 run hello-simulator
## [ 0%] Building CXX object examples/tutorial/CMakeFiles/hello-simulator.dir/hello-simulator.cc.o ## [ 0%] Linking CXX executable ../../../build/examples/tutorial/ns3.42-hello-simulator-default
## Hello Simulator
First: Point to Point
## Default Network Topology ## 10.1.1.0 ## n0 -------------- n1 ## point-to-point
./ns3 run first
## [ 0%] Building CXX object examples/tutorial/CMakeFiles/first.dir/first.cc.o ## [ 0%] Linking CXX executable ../../../build/examples/tutorial/ns3.42-first-default
## At time +2s client sent 1024 bytes to 10.1.1.2 port 9 ## At time +2.00369s server received 1024 bytes from 10.1.1.1 port 49153 ## At time +2.00369s server sent 1024 bytes to 10.1.1.1 port 49153 ## At time +2.00737s client received 1024 bytes from 10.1.1.2 port 9
Python
python3 ./examples/tutorial/first.py
## At time +2s client sent 1024 bytes to 10.1.1.2 port 9 ## At time +2.00369s server received 1024 bytes from 10.1.1.1 port 49153 ## At time +2.00369s server sent 1024 bytes to 10.1.1.1 port 49153 ## At time +2.00737s client received 1024 bytes from 10.1.1.2 port 9
Troubleshooting - No Visualizer
https://www.nsnam.org/wiki/PyViz
./ns3 run --vis first
## NS_ASSERT failed, cond="uid != 0", msg="Assert in TypeId::LookupByName: ns3::VisualSimulatorImpl not found", file=source/ns-3.42/src/core/model/type-id.cc, line=840 ## NS_FATAL, terminating ## terminate called without an active exception ## Command 'build/examples/tutorial/ns3.42-first-default --SimulatorImplementationType=ns3::VisualSimulatorImpl' died with <Signals.SIGABRT: 6>.
## Check if Python Bindings and PyViz Visualizer are ON ./ns3 show
Star Animation
./ns3 run star-animation
../netanim-3.109/NetAnim ## Open star-animation.xml on NetAnim
Dumbbell Animation
./ns3 run dumbbell-animation
../netanim-3.109/NetAnim ## Open dumbbell-animation.xml on NetAnim
References
Network Simulator (NS-3)
https://www.nsnam.org/
https://qiita.com/dorapon2000/items/5c0c0a399aeee629be63
https://qiita.com/bmt/items/b16d90730e9e398774f8
https://qiita.com/haltaro/items/b474d924f63692c155c8
https://qiita.com/RIckyBan/items/37ae69e991c125c5eb5f
Acknowledgments
Daiphys is a professional-service company for research and development of leading-edge technologies in science and engineering.
Get started accelerating your business through our deep expertise in R&D with AI, quantum computing, and space development; please get in touch with Daiphys today!
Daiphys Technologies LLC - https://www.daiphys.com/