Install NS3 under Ubuntu

Posted by jmelnick on Mon, 31 Jan 2022 17:02:15 +0100

Installing NS3 with bake under Ubuntu

ns3 Let me have to love, first contact ns3,I hope to study and discuss with my classmates!

[note] refer to the NS official website for the following operations:
https://www.nsnam.org/wiki/Installation#Installation

1) Platform selection

Choose Ubuntu here:

Depending on the package download, because there are many software packages, write the installation command into the shell script, add automatic confirmation -y, and then execute the script.
[note] if the speed is too slow, change the source first.

 #! /usr/bin
 apt-get install -y g++ python3 cmake		#The kernel of ns3 is developed using C + +
 apt-get install -y g++ python3 python3-dev pkg-config sqlite3 cmake
 apt-get install -y python3-setuptools git
 apt-get install -y qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools		#Netanim animator: netanim animator requires qt5 development tools
 
 #Support ns-3-pyviz visualization tool
 #Python pygoocanvas is no longer available for Ubuntu 18.04 and later. ns-3.29 and later versions will support upgrading to GTK + version 3 and require the following software packages:
 apt-get install -y gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3  
 
  #Support distributed simulation based on MPI
  apt-get install -y openmpi-bin openmpi-common openmpi-doc libopenmpi-dev
  
  #Support for building based on bake
  apt-get install -y autoconf cvs bzr unrar
  
  apt-get install -y gdb valgrind 
  apt-get install -y doxygen graphviz imagemagick
  apt-get install -y texlive texlive-extra-utils texlive-latex-extra texlive-font-utils dvipng latexmk
  
  #ns-3 manuals and tutorials
  apt-get install -y python3-sphinx dia 
  
  #The GNU Science Library (GSL) supports a more accurate 802.11b WiFi error model (not required for OFDM):
  apt-get install -y gsl-bin libgsl-dev libgslcblas0
  
  apt-get install -y tcpdump		#Read pcap packet trace
  apt-get install -y sqlite sqlite3 libsqlite3-dev		#Database support of statistical framework
  apt-get install -y libxml2 libxml2-dev		#XML based configuration storage Version (libxml2 > = version 2.7 required)
  
  #Supports the generation of modified python bindings
  apt-get install -y cmake libc6-dev libc6-dev-i386 libclang-dev llvm-dev automake python3-pip 
 python3 -m pip install --user cxxfilt
 
 apt-get install -y libgtk-3-dev		#GTK based configuration system
 apt-get install -y vtun lxc uml-utilities		#Test virtual machine and ns-3
 apt-get install -y  libxml2 libxml2-dev libboost-all-dev	#Support openflow module
 
 apt-get install -y mercurial		#Mercurial needs to be used with the ns-3 development repository.
 apt-get install -y python-dev		#

2) Installation

Install with Bake: Bake is a new tool for installing, building, and finding ns-3 missing requirements in your own environment.

This method is one word: slow
However, it is convenient not to have too many operations.

First download git

 git clone https://gitlab.com/nsnam/bake.git

Add related path

 export BAKE_HOME=`pwd`/bake 
 export PATH=$PATH:$BAKE_HOME
 export PYTHONPATH=$PYTHONPATH:$BAKE_HOME

Then test

bake.py check

Configure bake to tell it which modules you want to add to ns-3

bake.py configure -e ns-3.29

[note] there may be some problems here:

Problems writing the file, error: [Errno 13] Permission denied: '/ns3/bake/bakefile.xml'

(1) If the file does not exist in the directory, use touch to create it.
(2) Permission denied: this situation is encountered because the requested file or folder does not have permission, resulting in the server rejecting the request. The simple and direct method is to switch su root to root for operation.

Then, to view the added modules and the specific system requirements of this configuration, you can call bake show:

bake.py show	

#You can also see the specific system requirements in this option and download relevant modules

If there are still dependent packages to install at this time, download them according to the prompts.

Download the module, build and install it, and call bake deploy:

 bake.py deploy

But the ns-3.29 download failed at this time (I think it's a network problem)

 >> Downloading ns-3.29 - Problem
 > Error:  Critical dependency, module "ns-3.29" failed 
   For more information call Bake with --debug and/or -v, -vvv, for full verbose mode (bake --help)


Then choose another method to download ns (Using Git)
https://www.nsnam.org/wiki/Installation#Installation_with_Bake

git clone https://gitlab.com/nsnam/ns-3-allinone.git

Then download the corresponding version

 ./download.py -n ns-3.29

After the download is successful, build

 ./build.py

bake normal process: download the selected module and all its dependencies, and use all these independent modules to build ns-3

  bake.py download
  bake.py build

3) Testing

[note] the following operations are carried out in the downloaded ns3!

(1) Use test Py test

./test.py -c core

As you can see, as shown in the figure below:

(2) Run script test

./waf --run scratch-simulator

If the output is as shown in the figure below, the installation is successful!

If there is a problem in this step, that is, there is only 'build finished' and no output, you need to reconfigure and compile ns3

./waf -d debug --enable-examples --enable-tests configure
./waf

Then re execute the program to see if the result is output.

Topics: Linux Ubuntu bash