Installing ns 3 - nps-ros2/ns3_testbed GitHub Wiki
We use the ns-3 Network Simulator to flow network communication between robots. Specifically, we run robots within network namespaces and have the network simulator program flow network data between Tap devices within these network namespaces.
Install ns-3.30.1
-
Download zipped
ns-allinone-3.30.1
files from https://www.nsnam.org/releases/ns-3-30/download to~/repos
and extract. -
Build ns-3.30.1:
cd ~/repos/ns-allinone-3.30.1 ./build.py
-
Make ns-3 visible
Set library and path variables so your environment can find ns-3. Put this in your
~/.bashrc
file:# ns-3-custom compatibility export LD_LIBRARY_PATH=~/repos/ns-allinone-3.30.1/ns-3.30.1/build/lib:$LD_LIBRARY_PATH export PATH=$HOME/repos/ns-allinone-3.30.1/ns-3.30.1/build/src/fd-net-device:$HOME/repos/ns-allinone-3.30.1/ns-3.30.1/build/src/tap-bridge:$PATH
Install Custom ns-3.29 (old)
This is old. Use newer ns-3 instead. We keep this around because it shows how to customize ns-3 so it can print warnings when ns-3 cannot keep up.
-
Download ns-3.29 into
~/repos
using Mercurial (hg):sudo apt-get install mercurial mkdir ~/repos cd ~/repos hg clone http://code.nsnam.org/ns-3-allinone cd ns-3-allinone ./download.py -n ns-3.29
-
Fix ns-3.29 sudo bug: In file
~/repos/ns-3-allinone/ns-3.29/wscript
change lineprogram.create_task("SuidBuild")
toprogram.create_task("SuidBuild_task")
. -
Copy ns-3 to a work area where we will customize it:
cp -r ~/repos/ns-3-allinone ~/repos/ns-3-custom
-
Customize our new ns-3 copy to warn instead of fail when ns-3 cannot keep up and accuracy jitter exceeds 100 ms. Replace two files with files in the repository that have been modified to do this:
cp ~/gits/ns3_testbed/ns3_programs/ns_3_29_warn_mods/realtime-simulator-impl.cc ~/repos/ns-3-custom/ns-3.29/src/core/model cp ~/gits/ns3_testbed/ns3_programs/ns_3_29_warn_mods/realtime-simulator-impl.h ~/repos/ns-3-custom/ns-3.29/src/core/model
-
Configure and build the custom ns-3 using the ns-3
waf
build tool:cd ~/repos/ns-3-custom/ns-3.29 ./waf configure --enable-sudo ./waf build
-
Make ns-3 visible
Set library and path variables so your environment can find ns-3. Put this in your
~/.bashrc
file:# ns-3-custom compatibility export LD_LIBRARY_PATH=~/repos/ns-3-custom/ns-3.29/build/lib:$LD_LIBRARY_PATH export PATH=$HOME/repos/ns-3-custom/ns-3.29/build/src/fd-net-device:$HOME/repos/ns-3-custom/ns-3.29/build/src/tap-bridge:$PATH