2013-07-17 17:09:36 -07:00
|
|
|
|
.. include:: replace.txt
|
|
|
|
|
|
.. highlight:: bash
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
|
|
|
|
|
Getting Started
|
|
|
|
|
|
---------------
|
|
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
This section is aimed at getting a user to a working state starting
|
|
|
|
|
|
with a machine that may never have had |ns3| installed. It covers
|
|
|
|
|
|
supported platforms, prerequisites, ways to obtain |ns3|, ways to
|
|
|
|
|
|
build |ns3|, and ways to verify your build and run simple programs.
|
|
|
|
|
|
|
|
|
|
|
|
Overview
|
|
|
|
|
|
********
|
|
|
|
|
|
|
|
|
|
|
|
|ns3| is built as a system of software libraries that work together.
|
|
|
|
|
|
User programs can be written that links with (or imports from) these
|
|
|
|
|
|
libraries. User programs are written in either the C++ or Python
|
|
|
|
|
|
programming languages.
|
|
|
|
|
|
|
|
|
|
|
|
|ns3| is distributed as source code, meaning that the target system
|
|
|
|
|
|
needs to have a software development environment to build the libraries
|
|
|
|
|
|
first, then build the user program. |ns3| could in principle be
|
|
|
|
|
|
distributed as pre-built libraries for selected systems, and in the
|
|
|
|
|
|
future it may be distributed that way, but at present, many users
|
|
|
|
|
|
actually do their work by editing |ns3| itself, so having the source
|
|
|
|
|
|
code around to rebuild the libraries is useful. If someone would like
|
|
|
|
|
|
to undertake the job of making pre-built libraries and packages for
|
|
|
|
|
|
operating systems, please contact the ns-developers mailing list.
|
|
|
|
|
|
|
2013-05-09 22:38:09 -07:00
|
|
|
|
In the following, we'll look at two ways of downloading and building
|
|
|
|
|
|
|ns3|. The first is to download and build an official release
|
|
|
|
|
|
from the main web site. The second is to fetch and build development
|
|
|
|
|
|
copies of |ns3|. We'll walk through both examples since the tools
|
|
|
|
|
|
involved are slightly different.
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Downloading |ns3|
|
|
|
|
|
|
*****************
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
|
|
|
|
|
The |ns3| system as a whole is a fairly complex system and has a
|
2010-04-22 09:23:26 -07:00
|
|
|
|
number of dependencies on other components. Along with the systems you will
|
2012-06-04 07:21:57 -07:00
|
|
|
|
most likely deal with every day (the GNU toolchain, Mercurial, a text
|
2010-04-22 09:23:26 -07:00
|
|
|
|
editor) you will need to ensure that a number of additional libraries are
|
2011-01-02 22:57:32 -08:00
|
|
|
|
present on your system before proceeding. |ns3| provides a wiki
|
2013-05-05 22:42:12 -07:00
|
|
|
|
page that includes pages with many useful hints and tips.
|
2011-01-02 22:57:32 -08:00
|
|
|
|
One such page is the "Installation" page,
|
2013-11-13 16:06:43 -05:00
|
|
|
|
http://www.nsnam.org/wiki/Installation.
|
2010-04-22 09:23:26 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
The "Prerequisites" section of this wiki page explains which packages are
|
|
|
|
|
|
required to support common |ns3| options, and also provides the
|
2010-04-22 09:23:26 -07:00
|
|
|
|
commands used to install them for common Linux variants. Cygwin users will
|
|
|
|
|
|
have to use the Cygwin installer (if you are a Cygwin user, you used it to
|
|
|
|
|
|
install Cygwin).
|
|
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
You may want to take this opportunity to explore the |ns3| wiki
|
2010-04-22 09:23:26 -07:00
|
|
|
|
a bit since there really is a wealth of information there.
|
|
|
|
|
|
|
2008-06-30 11:42:38 -07:00
|
|
|
|
From this point forward, we are going to assume that the reader is working in
|
|
|
|
|
|
Linux or a Linux emulation environment (Linux, Cygwin, etc.) and has the GNU
|
2010-04-22 09:23:26 -07:00
|
|
|
|
toolchain installed and verified along with the prerequisites mentioned
|
|
|
|
|
|
above. We are also going to assume that you have Mercurial and Waf installed
|
2011-06-23 12:41:51 -07:00
|
|
|
|
and running on the target system.
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
|
|
|
|
|
The |ns3| code is available in Mercurial repositories on the server
|
|
|
|
|
|
http://code.nsnam.org. You can also download a tarball release at
|
2014-12-20 20:34:36 -08:00
|
|
|
|
http://www.nsnam.org/release/, or you can work with repositories
|
2009-03-24 00:51:10 -07:00
|
|
|
|
using Mercurial. We recommend using Mercurial unless there's a good reason
|
|
|
|
|
|
not to. See the end of this section for instructions on how to get a tarball
|
|
|
|
|
|
release.
|
|
|
|
|
|
|
|
|
|
|
|
The simplest way to get started using Mercurial repositories is to use the
|
2011-01-02 22:57:32 -08:00
|
|
|
|
``ns-3-allinone`` environment. This is a set of scripts that manages the
|
|
|
|
|
|
downloading and building of various subsystems of |ns3| for you. We
|
2013-05-05 22:42:12 -07:00
|
|
|
|
recommend that you begin your |ns3| work in this environment.
|
|
|
|
|
|
|
2015-02-05 11:54:48 -08:00
|
|
|
|
One practice is to create a directory called ``workspace`` in one's home
|
|
|
|
|
|
directory under which one can keep local Mercurial repositories.
|
|
|
|
|
|
Any directory name will do, but we'll assume that ``workspace`` is used
|
|
|
|
|
|
herein (note: ``repos`` may also be used in some documentation as
|
|
|
|
|
|
an example directory name).
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Downloading |ns3| Using a Tarball
|
|
|
|
|
|
+++++++++++++++++++++++++++++++++
|
2013-05-09 22:38:09 -07:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
A tarball is a particular format of software archive where multiple
|
|
|
|
|
|
files are bundled together and the archive possibly compressed.
|
|
|
|
|
|
|ns3| software releases are provided via a downloadable tarball.
|
|
|
|
|
|
The process for downloading |ns3| via tarball is simple; you just
|
|
|
|
|
|
have to pick a release, download it and decompress it.
|
|
|
|
|
|
|
|
|
|
|
|
Let's assume that you, as a user, wish to build |ns3| in a local
|
|
|
|
|
|
directory called ``workspace``.
|
|
|
|
|
|
If you adopt the ``workspace`` directory approach, you can
|
|
|
|
|
|
get a copy of a release by typing the following into your Linux shell
|
2014-02-04 16:14:44 -08:00
|
|
|
|
(substitute the appropriate version numbers, of course)::
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ cd
|
|
|
|
|
|
$ mkdir workspace
|
|
|
|
|
|
$ cd workspace
|
2015-05-13 11:12:28 -07:00
|
|
|
|
$ wget http://www.nsnam.org/release/ns-allinone-3.23.tar.bz2
|
|
|
|
|
|
$ tar xjf ns-allinone-3.23.tar.bz2
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2015-05-13 11:12:28 -07:00
|
|
|
|
If you change into the directory ``ns-allinone-3.23`` you should see a
|
2014-02-04 16:14:44 -08:00
|
|
|
|
number of files::
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ls
|
2015-05-13 11:12:28 -07:00
|
|
|
|
bake constants.py ns-3.23 README
|
|
|
|
|
|
build.py netanim-3.106 pybindgen-0.17.0.886 util.py
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2015-02-05 11:54:48 -08:00
|
|
|
|
You are now ready to build the base |ns3| distribution.
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Downloading |ns3| Using Bake
|
2013-05-09 22:38:09 -07:00
|
|
|
|
++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
|
|
Bake is a tool for distributed integration and building,
|
2015-02-05 11:54:48 -08:00
|
|
|
|
developed for the |ns3| project. Bake can be used to fetch development
|
|
|
|
|
|
versions of the |ns3| software, and to download and build extensions to the
|
|
|
|
|
|
base |ns3| distribution, such as the Direct Code Execution environment,
|
|
|
|
|
|
Network Simulation Cradle, ability to create new Python bindings, and
|
|
|
|
|
|
others.
|
|
|
|
|
|
|
|
|
|
|
|
In recent |ns3| releases, Bake has been included in the release
|
|
|
|
|
|
tarball. The configuration file included in the released version
|
|
|
|
|
|
will allow one to download any software that was current at the
|
|
|
|
|
|
time of the release. That is, for example, the version of Bake that
|
2015-02-05 13:02:44 -08:00
|
|
|
|
is distributed with the ``ns-3.21`` release can be used to fetch components
|
2015-02-05 11:54:48 -08:00
|
|
|
|
for that |ns3| release or earlier, but can't be used to fetch components
|
|
|
|
|
|
for later releases (unless the ``bakeconf.xml`` file is updated).
|
|
|
|
|
|
|
|
|
|
|
|
You can also get the most recent copy of ``bake`` by typing the
|
2014-02-04 16:14:44 -08:00
|
|
|
|
following into your Linux shell (assuming you have installed Mercurial)::
|
2012-12-04 13:56:31 +01:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ cd
|
|
|
|
|
|
$ mkdir workspace
|
|
|
|
|
|
$ cd workspace
|
|
|
|
|
|
$ hg clone http://code.nsnam.org/bake
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
|
|
|
|
|
As the hg (Mercurial) command executes, you should see something like the
|
|
|
|
|
|
following displayed,
|
|
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
...
|
2013-05-05 22:42:12 -07:00
|
|
|
|
destination directory: bake
|
2009-03-24 00:51:10 -07:00
|
|
|
|
requesting all changes
|
|
|
|
|
|
adding changesets
|
|
|
|
|
|
adding manifests
|
|
|
|
|
|
adding file changes
|
2015-02-05 11:54:48 -08:00
|
|
|
|
added 339 changesets with 796 changes to 63 files
|
2011-12-23 12:00:12 -08:00
|
|
|
|
updating to branch default
|
2013-05-05 22:42:12 -07:00
|
|
|
|
45 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
|
|
|
|
|
After the clone command completes, you should have a directory called
|
2014-02-04 16:14:44 -08:00
|
|
|
|
``bake``, the contents of which should look something like the following::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ls
|
2013-05-05 22:42:12 -07:00
|
|
|
|
bake bakeconf.xml doc generate-binary.py TODO
|
|
|
|
|
|
bake.py examples test
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
Notice that you really just downloaded some Python scripts and a Python
|
|
|
|
|
|
module called ``bake``. The next step
|
2011-01-02 22:57:32 -08:00
|
|
|
|
will be to use those scripts to download and build the |ns3|
|
2009-03-24 00:51:10 -07:00
|
|
|
|
distribution of your choice.
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2013-05-09 22:38:09 -07:00
|
|
|
|
There are a few configuration targets available:
|
|
|
|
|
|
|
2015-05-13 11:12:28 -07:00
|
|
|
|
1. ``ns-3.23``: the module corresponding to the release; it will download
|
2013-05-09 22:38:09 -07:00
|
|
|
|
components similar to the release tarball.
|
|
|
|
|
|
2. ``ns-3-dev``: a similar module but using the development code tree
|
2015-05-13 11:12:28 -07:00
|
|
|
|
3. ``ns-allinone-3.23``: the module that includes other optional features
|
2013-05-09 22:38:09 -07:00
|
|
|
|
such as click routing, openflow for |ns3|, and the Network Simulation
|
|
|
|
|
|
Cradle
|
|
|
|
|
|
4. ``ns-3-allinone``: similar to the released version of the allinone
|
|
|
|
|
|
module, but for development code.
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
|
|
|
|
|
The current development snapshot (unreleased) of |ns3| may be found
|
|
|
|
|
|
at http://code.nsnam.org/ns-3-dev/. The
|
2009-03-24 00:51:10 -07:00
|
|
|
|
developers attempt to keep these repository in consistent, working states but
|
|
|
|
|
|
they are in a development area with unreleased code present, so you may want
|
|
|
|
|
|
to consider staying with an official release if you do not need newly-
|
|
|
|
|
|
introduced features.
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2013-05-09 22:38:09 -07:00
|
|
|
|
You can find the latest version of the
|
2009-06-15 15:22:33 -07:00
|
|
|
|
code either by inspection of the repository list or by going to the
|
2011-06-23 12:41:51 -07:00
|
|
|
|
`"ns-3 Releases"
|
|
|
|
|
|
<http://www.nsnam.org/releases>`_
|
2013-05-09 22:38:09 -07:00
|
|
|
|
web page and clicking on the latest release link. We'll proceed in
|
2015-05-13 11:12:28 -07:00
|
|
|
|
this tutorial example with ``ns-3.23``.
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2013-05-09 22:38:09 -07:00
|
|
|
|
We are now going to use the bake tool to pull down the various pieces of
|
|
|
|
|
|
|ns3| you will be using. First, we'll say a word about running bake.
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2013-05-09 22:38:09 -07:00
|
|
|
|
bake works by downloading source packages into a source directory,
|
|
|
|
|
|
and installing libraries into a build directory. bake can be run
|
|
|
|
|
|
by referencing the binary, but if one chooses to run bake from
|
|
|
|
|
|
outside of the directory it was downloaded into, it is advisable
|
2014-11-26 16:03:44 -08:00
|
|
|
|
to put bake into your path, such as follows (Linux bash shell example).
|
|
|
|
|
|
First, change into the 'bake' directory, and then set the following
|
|
|
|
|
|
environment variables
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2014-11-26 16:03:44 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
|
|
$ export BAKE_HOME=`pwd`
|
|
|
|
|
|
$ export PATH=$PATH:$BAKE_HOME:$BAKE_HOME/build/bin
|
|
|
|
|
|
$ export PYTHONPATH=$PYTHONPATH:$BAKE_HOME:$BAKE_HOME/build/lib
|
2013-05-09 22:38:09 -07:00
|
|
|
|
|
2014-11-26 16:03:44 -08:00
|
|
|
|
This will put the bake.py program into the shell's path, and will allow
|
|
|
|
|
|
other programs to find executables and libraries created by bake. Although
|
|
|
|
|
|
several bake use cases do not require setting PATH and PYTHONPATH as above,
|
|
|
|
|
|
full builds of ns-3-allinone (with the optional packages) typically do.
|
2013-05-09 22:38:09 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Step into the workspace directory and type the following into your shell::
|
2013-05-09 22:38:09 -07:00
|
|
|
|
|
2015-05-13 11:12:28 -07:00
|
|
|
|
$ ./bake.py configure -e ns-3.23
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
Next, we'l ask bake to check whether we have enough tools to download
|
2014-02-04 16:14:44 -08:00
|
|
|
|
various components. Type::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./bake.py check
|
2009-07-01 23:08:07 -07:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
You should see something like the following,
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
> Python - OK
|
|
|
|
|
|
> GNU C++ compiler - OK
|
|
|
|
|
|
> Mercurial - OK
|
|
|
|
|
|
> CVS - OK
|
|
|
|
|
|
> GIT - OK
|
|
|
|
|
|
> Bazaar - OK
|
|
|
|
|
|
> Tar tool - OK
|
|
|
|
|
|
> Unzip tool - OK
|
|
|
|
|
|
> Unrar tool - is missing
|
|
|
|
|
|
> 7z data compression utility - OK
|
|
|
|
|
|
> XZ data compression utility - OK
|
|
|
|
|
|
> Make - OK
|
|
|
|
|
|
> cMake - OK
|
|
|
|
|
|
> patch tool - OK
|
|
|
|
|
|
> autoreconf tool - OK
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
> Path searched for tools: /usr/lib64/qt-3.3/bin /usr/lib64/ccache
|
|
|
|
|
|
/usr/local/bin /bin /usr/bin /usr/local/sbin /usr/sbin /sbin
|
|
|
|
|
|
/home/tomh/bin bin
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
In particular, download tools such as Mercurial, CVS, GIT, and Bazaar
|
2013-05-09 22:38:09 -07:00
|
|
|
|
are our principal concerns at this point, since they allow us to fetch
|
2015-02-05 11:54:48 -08:00
|
|
|
|
the code. Please install missing tools at this stage, in the usual
|
|
|
|
|
|
way for your system (if you are able to), or contact your system
|
|
|
|
|
|
administrator as needed to install these tools.
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Next, try to download the software::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ./bake.py download
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
should yield something like::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
>> Searching for system dependency pygoocanvas - OK
|
|
|
|
|
|
>> Searching for system dependency python-dev - OK
|
|
|
|
|
|
>> Searching for system dependency pygraphviz - OK
|
2015-05-13 11:12:28 -07:00
|
|
|
|
>> Downloading pybindgen-0.17.0.886 - OK
|
2013-05-05 22:42:12 -07:00
|
|
|
|
>> Searching for system dependency g++ - OK
|
|
|
|
|
|
>> Searching for system dependency qt4 - OK
|
2015-05-13 11:12:28 -07:00
|
|
|
|
>> Downloading netanim-3.106 - OK
|
|
|
|
|
|
>> Downloading ns-3.23 - OK
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
The above suggests that three sources have been downloaded. Check the
|
2014-02-04 16:14:44 -08:00
|
|
|
|
``source`` directory now and type ``ls``; one should see::
|
2008-09-15 21:37:40 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ls
|
2015-05-13 11:12:28 -07:00
|
|
|
|
netanim-3.106 ns-3.23 pybindgen-0.17.0.886
|
2008-06-29 21:16:35 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
You are now ready to build the |ns3| distribution.
|
2008-06-29 21:16:35 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Building |ns3|
|
|
|
|
|
|
**************
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Building with ``build.py``
|
|
|
|
|
|
++++++++++++++++++++++++++
|
2013-05-05 22:42:12 -07:00
|
|
|
|
When working from a released tarball, the first time you build the
|
|
|
|
|
|
|ns3| project you can build using a convenience program found in the
|
2011-12-27 14:13:26 -08:00
|
|
|
|
``allinone`` directory. This program is called ``build.py``. This
|
|
|
|
|
|
program will get the project configured for you
|
|
|
|
|
|
in the most commonly useful way. However, please note that more advanced
|
|
|
|
|
|
configuration and work with |ns3| will typically involve using the
|
|
|
|
|
|
native |ns3| build system, Waf, to be introduced later in this tutorial.
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
If you downloaded
|
2009-03-24 00:51:10 -07:00
|
|
|
|
using a tarball you should have a directory called something like
|
2015-05-13 11:12:28 -07:00
|
|
|
|
``ns-allinone-3.23`` under your ``~/workspace`` directory.
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Type the following::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./build.py --enable-examples --enable-tests
|
2011-04-06 10:13:04 -07:00
|
|
|
|
|
2011-04-12 14:35:16 -07:00
|
|
|
|
Because we are working with examples and tests in this tutorial, and
|
|
|
|
|
|
because they are not built by default in |ns3|, the arguments for
|
2011-12-27 14:13:26 -08:00
|
|
|
|
build.py tells it to build them for us. The program also defaults to
|
|
|
|
|
|
building all available modules. Later, you can build
|
|
|
|
|
|
|ns3| without examples and tests, or eliminate the modules that
|
|
|
|
|
|
are not necessary for your work, if you wish.
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
|
|
|
|
|
You will see lots of typical compiler output messages displayed as the build
|
|
|
|
|
|
script builds the various pieces you downloaded. Eventually you should see the
|
2015-02-05 11:54:48 -08:00
|
|
|
|
following::
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2015-05-13 11:12:28 -07:00
|
|
|
|
Waf: Leaving directory `/path/to/workspace/ns-allinone-3.23/ns-3.23/build'
|
2013-05-05 22:42:12 -07:00
|
|
|
|
'build' finished successfully (6m25.032s)
|
2011-04-19 10:30:50 -07:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
Modules built:
|
|
|
|
|
|
antenna aodv applications
|
|
|
|
|
|
bridge buildings config-store
|
|
|
|
|
|
core csma csma-layout
|
2015-02-05 11:54:48 -08:00
|
|
|
|
dsdv dsr energy
|
|
|
|
|
|
fd-net-device flow-monitor internet
|
|
|
|
|
|
lr-wpan lte mesh
|
2013-05-05 22:42:12 -07:00
|
|
|
|
mobility mpi netanim (no Python)
|
|
|
|
|
|
network nix-vector-routing olsr
|
|
|
|
|
|
point-to-point point-to-point-layout propagation
|
2015-02-05 11:54:48 -08:00
|
|
|
|
sixlowpan spectrum stats
|
|
|
|
|
|
tap-bridge test (no Python) topology-read
|
2015-02-05 13:02:44 -08:00
|
|
|
|
uan virtual-net-device wave
|
2015-02-05 11:54:48 -08:00
|
|
|
|
wifi wimax
|
|
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
Modules not built (see ns-3 tutorial for explanation):
|
|
|
|
|
|
brite click openflow
|
|
|
|
|
|
visualizer
|
|
|
|
|
|
|
2015-05-13 11:12:28 -07:00
|
|
|
|
Leaving directory `./ns-3.23'
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Regarding the portion about modules not built::
|
2012-12-05 20:45:38 -08:00
|
|
|
|
|
|
|
|
|
|
Modules not built (see ns-3 tutorial for explanation):
|
2013-05-05 22:42:12 -07:00
|
|
|
|
brite click openflow
|
|
|
|
|
|
visualizer
|
2012-12-05 20:45:38 -08:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
This just means that some |ns3| modules that have dependencies on
|
2012-12-05 20:45:38 -08:00
|
|
|
|
outside libraries may not have been built, or that the configuration
|
|
|
|
|
|
specifically asked not to build them. It does not mean that the
|
|
|
|
|
|
simulator did not build successfully or that it will provide wrong
|
|
|
|
|
|
results for the modules listed as being built.
|
|
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
Building with bake
|
|
|
|
|
|
++++++++++++++++++
|
|
|
|
|
|
|
|
|
|
|
|
If you used bake above to fetch source code from project repositories, you
|
|
|
|
|
|
may continue to use it to build |ns3|. Type
|
|
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./bake.py build
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
and you should see something like::
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2015-05-13 11:12:28 -07:00
|
|
|
|
>> Building pybindgen-0.17.0.886 - OK
|
|
|
|
|
|
>> Building netanim-3.106 - OK
|
|
|
|
|
|
>> Building ns-3.23 - OK
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
2013-05-09 22:38:09 -07:00
|
|
|
|
*Hint: you can also perform both steps, download and build by calling 'bake.py deploy'.*
|
|
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
If there happens to be a failure, please have a look at what the following
|
2014-02-04 16:14:44 -08:00
|
|
|
|
command tells you; it may give a hint as to a missing dependency::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./bake.py show
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
|
|
|
|
|
This will list out the various dependencies of the packages you are
|
|
|
|
|
|
trying to build.
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
|
|
|
|
|
Building with Waf
|
|
|
|
|
|
+++++++++++++++++
|
2013-05-05 22:42:12 -07:00
|
|
|
|
|
|
|
|
|
|
Up to this point, we have used either the `build.py` script, or the
|
|
|
|
|
|
`bake` tool, to get started with building |ns3|. These tools are useful
|
|
|
|
|
|
for building |ns3| and supporting libraries, and they call into
|
|
|
|
|
|
the |ns3| directory to call the Waf build tool to do the actual building.
|
|
|
|
|
|
Most users quickly transition to using Waf directly to configure and
|
|
|
|
|
|
build |ns3|. So, to proceed, please change your working directory to
|
|
|
|
|
|
the |ns3| directory that you have initially built.
|
|
|
|
|
|
|
2011-12-27 14:13:26 -08:00
|
|
|
|
It's not
|
2009-03-24 00:51:10 -07:00
|
|
|
|
strictly required at this point, but it will be valuable to take a slight
|
|
|
|
|
|
detour and look at how to make changes to the configuration of the project.
|
|
|
|
|
|
Probably the most useful configuration change you can make will be to
|
|
|
|
|
|
build the optimized version of the code. By default you have configured
|
2011-04-06 10:13:04 -07:00
|
|
|
|
your project to build the debug version. Let's tell the project to
|
2009-03-24 00:51:10 -07:00
|
|
|
|
make an optimized build. To explain to Waf that it should do optimized
|
2011-04-12 14:35:16 -07:00
|
|
|
|
builds that include the examples and tests, you will need to execute the
|
2014-02-04 16:14:44 -08:00
|
|
|
|
following commands::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./waf clean
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ./waf --build-profile=optimized --enable-examples --enable-tests configure
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2008-06-29 21:16:35 -07:00
|
|
|
|
This runs Waf out of the local directory (which is provided as a convenience
|
2011-12-27 14:13:26 -08:00
|
|
|
|
for you). The first command to clean out the previous build is not
|
2014-02-04 16:14:44 -08:00
|
|
|
|
typically strictly necessary but is good practice (but see `Build Profiles`_,
|
|
|
|
|
|
below); it will remove the
|
2011-12-27 14:13:26 -08:00
|
|
|
|
previously built libraries and object files found in directory ``build/``.
|
|
|
|
|
|
When the project is reconfigured and the build system checks for various
|
|
|
|
|
|
dependencies, you should see
|
2014-02-04 16:14:44 -08:00
|
|
|
|
output that looks similar to the following::
|
|
|
|
|
|
|
|
|
|
|
|
Setting top to : .
|
|
|
|
|
|
Setting out to : build
|
|
|
|
|
|
Checking for 'gcc' (c compiler) : /usr/bin/gcc
|
|
|
|
|
|
Checking for cc version : 4.2.1
|
|
|
|
|
|
Checking for 'g++' (c++ compiler) : /usr/bin/g++
|
|
|
|
|
|
Checking boost includes : 1_46_1
|
|
|
|
|
|
Checking boost libs : ok
|
|
|
|
|
|
Checking for boost linkage : ok
|
|
|
|
|
|
Checking for click location : not found
|
|
|
|
|
|
Checking for program pkg-config : /sw/bin/pkg-config
|
|
|
|
|
|
Checking for 'gtk+-2.0' >= 2.12 : yes
|
|
|
|
|
|
Checking for 'libxml-2.0' >= 2.7 : yes
|
|
|
|
|
|
Checking for type uint128_t : not found
|
|
|
|
|
|
Checking for type __uint128_t : yes
|
|
|
|
|
|
Checking high precision implementation : 128-bit integer (default)
|
|
|
|
|
|
Checking for header stdint.h : yes
|
|
|
|
|
|
Checking for header inttypes.h : yes
|
|
|
|
|
|
Checking for header sys/inttypes.h : not found
|
|
|
|
|
|
Checking for header sys/types.h : yes
|
|
|
|
|
|
Checking for header sys/stat.h : yes
|
|
|
|
|
|
Checking for header dirent.h : yes
|
|
|
|
|
|
Checking for header stdlib.h : yes
|
|
|
|
|
|
Checking for header signal.h : yes
|
|
|
|
|
|
Checking for header pthread.h : yes
|
|
|
|
|
|
Checking for header stdint.h : yes
|
|
|
|
|
|
Checking for header inttypes.h : yes
|
|
|
|
|
|
Checking for header sys/inttypes.h : not found
|
|
|
|
|
|
Checking for library rt : not found
|
|
|
|
|
|
Checking for header netpacket/packet.h : not found
|
|
|
|
|
|
Checking for header sys/ioctl.h : yes
|
|
|
|
|
|
Checking for header net/if.h : not found
|
|
|
|
|
|
Checking for header net/ethernet.h : yes
|
|
|
|
|
|
Checking for header linux/if_tun.h : not found
|
|
|
|
|
|
Checking for header netpacket/packet.h : not found
|
|
|
|
|
|
Checking for NSC location : not found
|
|
|
|
|
|
Checking for 'mpic++' : yes
|
|
|
|
|
|
Checking for 'sqlite3' : yes
|
|
|
|
|
|
Checking for header linux/if_tun.h : not found
|
|
|
|
|
|
Checking for program sudo : /usr/bin/sudo
|
|
|
|
|
|
Checking for program valgrind : /sw/bin/valgrind
|
|
|
|
|
|
Checking for 'gsl' : yes
|
|
|
|
|
|
Checking for compilation flag -Wno-error=deprecated-d... support : ok
|
|
|
|
|
|
Checking for compilation flag -Wno-error=deprecated-d... support : ok
|
|
|
|
|
|
Checking for compilation flag -fstrict-aliasing... support : ok
|
|
|
|
|
|
Checking for compilation flag -fstrict-aliasing... support : ok
|
|
|
|
|
|
Checking for compilation flag -Wstrict-aliasing... support : ok
|
|
|
|
|
|
Checking for compilation flag -Wstrict-aliasing... support : ok
|
|
|
|
|
|
Checking for program doxygen : /usr/local/bin/doxygen
|
2009-07-01 23:08:07 -07:00
|
|
|
|
---- Summary of optional NS-3 features:
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Build profile : debug
|
|
|
|
|
|
Build directory : build
|
|
|
|
|
|
Python Bindings : enabled
|
|
|
|
|
|
BRITE Integration : not enabled (BRITE not enabled (see option --with-brite))
|
|
|
|
|
|
NS-3 Click Integration : not enabled (nsclick not enabled (see option --with-nsclick))
|
2009-07-01 23:08:07 -07:00
|
|
|
|
GtkConfigStore : enabled
|
|
|
|
|
|
XmlIo : enabled
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Threading Primitives : enabled
|
|
|
|
|
|
Real Time Simulator : enabled (librt is not available)
|
|
|
|
|
|
Emulated Net Device : enabled (<netpacket/packet.h> include not detected)
|
|
|
|
|
|
File descriptor NetDevice : enabled
|
|
|
|
|
|
Tap FdNetDevice : not enabled (needs linux/if_tun.h)
|
|
|
|
|
|
Emulation FdNetDevice : not enabled (needs netpacket/packet.h)
|
|
|
|
|
|
PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
|
|
|
|
|
|
Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
|
|
|
|
|
|
MPI Support : enabled
|
|
|
|
|
|
NS-3 OpenFlow Integration : not enabled (Required boost libraries not found, missing: system, signals, filesystem)
|
2009-07-01 23:08:07 -07:00
|
|
|
|
SQlite stats data output : enabled
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Tap Bridge : not enabled (<linux/if_tun.h> include not detected)
|
|
|
|
|
|
PyViz visualizer : enabled
|
2009-07-01 23:08:07 -07:00
|
|
|
|
Use sudo to set suid bit : not enabled (option --enable-sudo not selected)
|
2011-04-19 10:30:50 -07:00
|
|
|
|
Build tests : enabled
|
2011-04-14 14:22:09 -07:00
|
|
|
|
Build examples : enabled
|
2014-02-04 16:14:44 -08:00
|
|
|
|
GNU Scientific Library (GSL) : enabled
|
|
|
|
|
|
'configure' finished successfully (1.944s)
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Note the last part of the above output. Some |ns3| options are not enabled by
|
2009-06-15 15:22:33 -07:00
|
|
|
|
default or require support from the underlying system to work properly.
|
2009-03-24 00:51:10 -07:00
|
|
|
|
For instance, to enable XmlTo, the library libxml-2.0 must be found on the
|
2011-01-02 22:57:32 -08:00
|
|
|
|
system. If this library were not found, the corresponding |ns3| feature
|
2009-07-01 23:08:07 -07:00
|
|
|
|
would not be enabled and a message would be displayed. Note further that there is
|
2011-01-02 22:57:32 -08:00
|
|
|
|
a feature to use the program ``sudo`` to set the suid bit of certain programs.
|
|
|
|
|
|
This is not enabled by default and so this feature is reported as "not enabled."
|
2008-09-15 21:37:40 -07:00
|
|
|
|
|
2011-04-12 14:35:16 -07:00
|
|
|
|
Now go ahead and switch back to the debug build that includes the examples and tests.
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./waf clean
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ./waf --build-profile=debug --enable-examples --enable-tests configure
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2009-03-24 00:51:10 -07:00
|
|
|
|
The build system is now configured and you can build the debug versions of
|
2011-12-23 12:00:12 -08:00
|
|
|
|
the |ns3| programs by simply typing
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
|
|
|
|
|
::
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./waf
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2011-12-27 14:13:26 -08:00
|
|
|
|
Okay, sorry, I made you build the |ns3| part of the system twice,
|
|
|
|
|
|
but now you know how to change the configuration and build optimized code.
|
|
|
|
|
|
|
2014-11-04 09:30:54 -08:00
|
|
|
|
The build.py script discussed above supports also the ``--enable-examples``
|
|
|
|
|
|
and ``enable-tests`` arguments, but in general, does not directly support
|
|
|
|
|
|
other waf options; for example, this will not work:
|
|
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
|
|
$ ./build.py --disable-python
|
|
|
|
|
|
|
|
|
|
|
|
will result in
|
|
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
|
|
build.py: error: no such option: --disable-python
|
|
|
|
|
|
|
|
|
|
|
|
However, the special operator ``--`` can be used to pass additional
|
|
|
|
|
|
options through to waf, so instead of the above, the following will work:
|
|
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
|
|
$ ./build.py -- --disable-python
|
|
|
|
|
|
|
|
|
|
|
|
as it generates the underlying command ``./waf configure --disable-python``.
|
|
|
|
|
|
|
2011-12-27 14:13:26 -08:00
|
|
|
|
Here are a few more introductory tips about Waf.
|
2014-02-04 16:14:44 -08:00
|
|
|
|
|
|
|
|
|
|
Configure vs. Build
|
|
|
|
|
|
===================
|
|
|
|
|
|
|
|
|
|
|
|
Some Waf commands are only meaningful during the configure phase and some commands are valid
|
|
|
|
|
|
in the build phase. For example, if you wanted to use the emulation
|
2011-04-06 10:13:04 -07:00
|
|
|
|
features of |ns3|, you might want to enable setting the suid bit using
|
2009-07-01 23:08:07 -07:00
|
|
|
|
sudo as described above. This turns out to be a configuration-time command, and so
|
2014-02-04 16:14:44 -08:00
|
|
|
|
you could reconfigure using the following command that also includes the examples and tests.
|
2009-03-25 09:34:39 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ./waf configure --enable-sudo --enable-examples --enable-tests
|
2009-03-25 09:34:39 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
If you do this, Waf will have run sudo to change the socket creator programs of the
|
|
|
|
|
|
emulation code to run as root.
|
2009-03-25 09:34:39 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
There are many other configure- and build-time options
|
|
|
|
|
|
available in Waf. To explore these options, type::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./waf --help
|
2009-03-25 09:34:39 -07:00
|
|
|
|
|
|
|
|
|
|
We'll use some of the testing-related commands in the next section.
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Build Profiles
|
|
|
|
|
|
==============
|
2011-12-27 14:13:26 -08:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
We already saw how you can configure Waf for ``debug`` or ``optimized`` builds::
|
2011-12-27 14:13:26 -08:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ./waf --build-profile=debug
|
2011-12-27 14:13:26 -08:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
There is also an intermediate build profile, ``release``. ``-d`` is a
|
|
|
|
|
|
synonym for ``--build-profile``.
|
2009-03-24 00:51:10 -07:00
|
|
|
|
|
2015-07-28 16:33:35 -07:00
|
|
|
|
The build profile controls the use of logging, assertions, and compiler optimization:
|
|
|
|
|
|
|
|
|
|
|
|
+--------------------+---------------------------------+-----------------------------------------------------------------+
|
|
|
|
|
|
| Feature | Build Profile |
|
|
|
|
|
|
+ +---------------------------------+-------------------------------+---------------------------------+
|
|
|
|
|
|
| | ``debug`` | ``release`` | ``optimized`` |
|
|
|
|
|
|
+====================+=================================+===============================+=================================+
|
|
|
|
|
|
| Enabled Features | | ``NS3_BUILD_PROFILE_DEBUG`` | ``NS3_BUILD_PROFILE_RELEASE`` | ``NS3_BUILD_PROFILE_OPTIMIZED`` |
|
|
|
|
|
|
| | | ``NS_LOG...`` | | |
|
|
|
|
|
|
| | | ``NS_ASSERT...`` | | |
|
|
|
|
|
|
+--------------------+---------------------------------+-------------------------------+---------------------------------+
|
|
|
|
|
|
| Code Wrapper Macro | ``NS_BUILD_DEBUG(code)`` | ``NS_BUILD_RELEASE(code)`` | ``NS_BUILD_OPTIMIZED(code)`` |
|
|
|
|
|
|
+--------------------+---------------------------------+-------------------------------+---------------------------------+
|
|
|
|
|
|
| Compiler Flags | ``-O0 -ggdb -g3`` | ``-O3 -g0`` | ``-O3 -g`` |
|
|
|
|
|
|
| | | ``-fomit-frame-pointer`` | ``-fstrict-overflow`` |
|
|
|
|
|
|
| | | | ``-march=native`` |
|
|
|
|
|
|
+--------------------+---------------------------------+-------------------------------+---------------------------------+
|
|
|
|
|
|
|
|
|
|
|
|
As you can see, logging and assertions are only available in debug builds.
|
|
|
|
|
|
Recommended practice is to develop your scenario in debug mode, then
|
|
|
|
|
|
conduct repetitive runs (for statistics or changing parameters) in
|
|
|
|
|
|
optimized build profile.
|
|
|
|
|
|
|
|
|
|
|
|
If you have code that should only run in specific build profiles,
|
|
|
|
|
|
use the indicated Code Wrapper macro:
|
|
|
|
|
|
|
|
|
|
|
|
.. sourcecode:: cpp
|
|
|
|
|
|
|
|
|
|
|
|
NS_BUILD_DEBUG (std::cout << "Part of an output line..." << std::flush; timer.Start ());
|
|
|
|
|
|
DoLongInvolvedComputation ();
|
|
|
|
|
|
NS_BUILD_DEBUG (timer.Stop (); std::cout << "Done: " << timer << std::endl;)
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
By default Waf puts the build artifacts in the ``build`` directory.
|
|
|
|
|
|
You can specify a different output directory with the ``--out``
|
|
|
|
|
|
option, e.g.
|
2012-12-12 19:52:06 +01:00
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ./waf configure --out=foo
|
|
|
|
|
|
|
|
|
|
|
|
Combining this with build profiles lets you switch between the different
|
|
|
|
|
|
compile options in a clean way::
|
|
|
|
|
|
|
|
|
|
|
|
$ ./waf configure --build-profile=debug --out=build/debug
|
|
|
|
|
|
$ ./waf build
|
|
|
|
|
|
...
|
|
|
|
|
|
$ ./waf configure --build-profile=optimized --out=build/optimized
|
|
|
|
|
|
$ ./waf build
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
This allows you to work with multiple builds rather than always
|
|
|
|
|
|
overwriting the last build. When you switch, Waf will only compile
|
|
|
|
|
|
what it has to, instead of recompiling everything.
|
|
|
|
|
|
|
|
|
|
|
|
When you do switch build profiles like this, you have to be careful
|
|
|
|
|
|
to give the same configuration parameters each time. It may be convenient
|
|
|
|
|
|
to define some environment variables to help you avoid mistakes::
|
|
|
|
|
|
|
|
|
|
|
|
$ export NS3CONFIG="--enable-examples --enable-tests"
|
|
|
|
|
|
$ export NS3DEBUG="--build-profile=debug --out=build/debug"
|
|
|
|
|
|
$ export NS3OPT=="--build-profile=optimized --out=build/optimized"
|
|
|
|
|
|
|
|
|
|
|
|
$ ./waf configure $NS3CONFIG $NS3DEBUG
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./waf build
|
2014-02-04 16:14:44 -08:00
|
|
|
|
...
|
|
|
|
|
|
$ ./waf configure $NS3CONFIG $NS3OPT
|
|
|
|
|
|
$ ./waf build
|
|
|
|
|
|
|
2015-07-28 16:33:35 -07:00
|
|
|
|
Compilers and Flags
|
|
|
|
|
|
===================
|
2012-12-12 19:52:06 +01:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
In the examples above, Waf uses the GCC C++ compiler, ``g++``, for
|
|
|
|
|
|
building |ns3|. However, it's possible to change the C++ compiler used by Waf
|
|
|
|
|
|
by defining the ``CXX`` environment variable.
|
|
|
|
|
|
For example, to use the Clang C++ compiler, ``clang++``,
|
2012-12-12 19:52:06 +01:00
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ CXX="clang++" ./waf configure
|
|
|
|
|
|
$ ./waf build
|
|
|
|
|
|
|
|
|
|
|
|
One can also set up Waf to do distributed compilation with ``distcc`` in
|
|
|
|
|
|
a similar way::
|
|
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ CXX="distcc g++" ./waf configure
|
|
|
|
|
|
$ ./waf build
|
2012-12-12 19:52:06 +01:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
More info on ``distcc`` and distributed compilation can be found on it's
|
2012-12-12 19:52:06 +01:00
|
|
|
|
`project page
|
|
|
|
|
|
<http://code.google.com/p/distcc/>`_
|
|
|
|
|
|
under Documentation section.
|
|
|
|
|
|
|
2015-07-28 16:33:35 -07:00
|
|
|
|
To add compiler flags, use the ``CXXFLAGS_EXTRA`` environment variable when
|
|
|
|
|
|
you configure |ns3|.
|
|
|
|
|
|
|
2014-11-04 10:54:48 -08:00
|
|
|
|
Install
|
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
|
|
Waf may be used to install libraries in various places on the system.
|
|
|
|
|
|
The default location where libraries and executables are built is
|
|
|
|
|
|
in the ``build`` directory, and because Waf knows the location of these
|
|
|
|
|
|
libraries and executables, it is not necessary to install the libraries
|
|
|
|
|
|
elsewhere.
|
|
|
|
|
|
|
|
|
|
|
|
If users choose to install things outside of the build directory, users
|
|
|
|
|
|
may issue the ``./waf install`` command. By default, the prefix for
|
|
|
|
|
|
installation is ``/usr/local``, so ``./waf install`` will install programs
|
|
|
|
|
|
into ``/usr/local/bin``, libraries into ``/usr/local/lib``, and headers
|
|
|
|
|
|
into ``/usr/local/include``. Superuser privileges are typically needed
|
|
|
|
|
|
to install to the default prefix, so the typical command would be
|
|
|
|
|
|
``sudo ./waf install``. When running programs with Waf, Waf will
|
|
|
|
|
|
first prefer to use shared libraries in the build directory, then
|
|
|
|
|
|
will look for libraries in the library path configured in the local
|
|
|
|
|
|
environment. So when installing libraries to the system, it is good
|
|
|
|
|
|
practice to check that the intended libraries are being used.
|
|
|
|
|
|
|
|
|
|
|
|
Users may choose to install to a different prefix by passing the ``--prefix``
|
|
|
|
|
|
option at configure time, such as:
|
|
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
|
|
./waf configure --prefix=/opt/local
|
|
|
|
|
|
|
|
|
|
|
|
If later after the build the user issues the ``./waf install`` command, the
|
|
|
|
|
|
prefix ``/opt/local`` will be used.
|
|
|
|
|
|
|
|
|
|
|
|
The ``./waf clean`` command should be used prior to reconfiguring
|
|
|
|
|
|
the project if Waf will be used to install things at a different prefix.
|
|
|
|
|
|
|
|
|
|
|
|
In summary, it is not necessary to call ``./waf install`` to use |ns3|.
|
|
|
|
|
|
Most users will not need this command since Waf will pick up the
|
|
|
|
|
|
current libraries from the ``build`` directory, but some users may find
|
|
|
|
|
|
it useful if their use case involves working with programs outside
|
|
|
|
|
|
of the |ns3| directory.
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
One Waf
|
|
|
|
|
|
=======
|
2008-06-29 21:16:35 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
There is only one Waf script, at the top level of the |ns3| source tree.
|
|
|
|
|
|
As you work, you may find yourself spending a lot of time in ``scratch/``,
|
|
|
|
|
|
or deep in ``src/...``, and needing to invoke Waf. You could just
|
|
|
|
|
|
remember where you are, and invoke Waf like this::
|
2008-06-29 21:16:35 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ../../../waf ...
|
|
|
|
|
|
|
2015-02-06 06:50:48 -08:00
|
|
|
|
but that gets tedious, and error prone, and there are better solutions.
|
2014-02-04 16:14:44 -08:00
|
|
|
|
|
|
|
|
|
|
If you have the full |ns3| repository this little gem is a start::
|
|
|
|
|
|
|
|
|
|
|
|
$ cd $(hg root) && ./waf ...
|
|
|
|
|
|
|
|
|
|
|
|
Even better is to define this as a shell function::
|
|
|
|
|
|
|
|
|
|
|
|
$ function waff { cd $(hg root) && ./waf $* ; }
|
|
|
|
|
|
|
|
|
|
|
|
$ waff build
|
|
|
|
|
|
|
|
|
|
|
|
If you only have the tarball, an environment variable can help::
|
|
|
|
|
|
|
|
|
|
|
|
$ export NS3DIR="$PWD"
|
|
|
|
|
|
$ function waff { cd $NS3DIR && ./waf $* ; }
|
|
|
|
|
|
|
|
|
|
|
|
$ cd scratch
|
|
|
|
|
|
$ waff build
|
|
|
|
|
|
|
|
|
|
|
|
It might be tempting in a module directory to add a trivial ``waf``
|
|
|
|
|
|
script along the lines of ``exec ../../waf``. Please don't. It's
|
|
|
|
|
|
confusing to new-comers, and when done poorly it leads to subtle build
|
|
|
|
|
|
errors. The solutions above are the way to go.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Testing |ns3|
|
|
|
|
|
|
*************
|
|
|
|
|
|
|
|
|
|
|
|
You can run the unit tests of the |ns3| distribution by running the
|
|
|
|
|
|
``./test.py -c core`` script::
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./test.py -c core
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
These tests are run in parallel by Waf. You should eventually
|
|
|
|
|
|
see a report saying that
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
2011-12-23 12:00:12 -08:00
|
|
|
|
92 of 92 tests passed (92 passed, 0 failed, 0 crashed, 0 valgrind errors)
|
2009-07-01 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
|
This is the important message.
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
You will also see the summary output from Waf and the test runner
|
|
|
|
|
|
executing each test, which will actually look something like::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-05-05 22:42:12 -07:00
|
|
|
|
Waf: Entering directory `/path/to/workspace/ns-3-allinone/ns-3-dev/build'
|
|
|
|
|
|
Waf: Leaving directory `/path/to/workspace/ns-3-allinone/ns-3-dev/build'
|
2009-10-09 20:50:49 -07:00
|
|
|
|
'build' finished successfully (1.799s)
|
2011-04-19 10:30:50 -07:00
|
|
|
|
|
|
|
|
|
|
Modules built:
|
2011-05-25 08:57:47 +04:00
|
|
|
|
aodv applications bridge
|
|
|
|
|
|
click config-store core
|
|
|
|
|
|
csma csma-layout dsdv
|
|
|
|
|
|
emu energy flow-monitor
|
|
|
|
|
|
internet lte mesh
|
|
|
|
|
|
mobility mpi netanim
|
|
|
|
|
|
network nix-vector-routing ns3tcp
|
|
|
|
|
|
ns3wifi olsr openflow
|
|
|
|
|
|
point-to-point point-to-point-layout propagation
|
|
|
|
|
|
spectrum stats tap-bridge
|
|
|
|
|
|
template test tools
|
|
|
|
|
|
topology-read uan virtual-net-device
|
|
|
|
|
|
visualizer wifi wimax
|
2011-04-19 10:30:50 -07:00
|
|
|
|
|
2009-10-09 20:50:49 -07:00
|
|
|
|
PASS: TestSuite ns3-wifi-interference
|
|
|
|
|
|
PASS: TestSuite histogram
|
2009-07-01 23:08:07 -07:00
|
|
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
2009-10-09 20:50:49 -07:00
|
|
|
|
PASS: TestSuite object
|
|
|
|
|
|
PASS: TestSuite random-number-generators
|
2011-12-23 12:00:12 -08:00
|
|
|
|
92 of 92 tests passed (92 passed, 0 failed, 0 crashed, 0 valgrind errors)
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2011-12-23 12:00:12 -08:00
|
|
|
|
This command is typically run by users to quickly verify that an
|
2014-02-04 16:14:44 -08:00
|
|
|
|
|ns3| distribution has built correctly. (Note the order of the ``PASS: ...``
|
|
|
|
|
|
lines can vary, which is okay. What's important is that the summary line at
|
|
|
|
|
|
the end report that all tests passed; none failed or crashed.)
|
2008-06-29 21:16:35 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
Running a Script
|
|
|
|
|
|
****************
|
2014-02-04 16:14:44 -08:00
|
|
|
|
|
2008-06-28 19:46:55 -07:00
|
|
|
|
We typically run scripts under the control of Waf. This allows the build
|
|
|
|
|
|
system to ensure that the shared library paths are set correctly and that
|
|
|
|
|
|
the libraries are available at run time. To run a program, simply use the
|
2011-01-02 22:57:32 -08:00
|
|
|
|
``--run`` option in Waf. Let's run the |ns3| equivalent of the
|
2014-02-04 16:14:44 -08:00
|
|
|
|
ubiquitous hello world program by typing the following::
|
2011-01-02 22:57:32 -08:00
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./waf --run hello-simulator
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
|
|
|
|
|
Waf first checks to make sure that the program is built correctly and
|
2009-06-15 15:22:33 -07:00
|
|
|
|
executes a build if required. Waf then executes the program, which
|
2008-06-28 19:46:55 -07:00
|
|
|
|
produces the following output.
|
|
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
2008-06-28 19:46:55 -07:00
|
|
|
|
Hello Simulator
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Congratulations! You are now an ns-3 user!
|
2008-06-30 11:42:38 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
**What do I do if I don't see the output?**
|
2010-03-19 15:54:01 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
If you see Waf messages indicating that the build was
|
2011-01-02 22:57:32 -08:00
|
|
|
|
completed successfully, but do not see the "Hello Simulator" output,
|
2014-02-04 16:14:44 -08:00
|
|
|
|
chances are that you have switched your build mode to ``optimized`` in
|
|
|
|
|
|
the `Building with Waf`_ section, but have missed the change back to
|
|
|
|
|
|
``debug`` mode. All of the console output used in this tutorial uses a
|
2011-01-02 22:57:32 -08:00
|
|
|
|
special |ns3| logging component that is useful for printing
|
2010-03-19 15:54:01 -07:00
|
|
|
|
user messages to the console. Output from this component is
|
|
|
|
|
|
automatically disabled when you compile optimized code -- it is
|
2011-01-02 22:57:32 -08:00
|
|
|
|
"optimized out." If you don't see the "Hello Simulator" output,
|
2014-02-04 16:14:44 -08:00
|
|
|
|
type the following::
|
2010-03-19 15:54:01 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
$ ./waf configure --build-profile=debug --enable-examples --enable-tests
|
2010-03-19 15:54:01 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
to tell Waf to build the debug versions of the |ns3|
|
2011-04-12 14:35:16 -07:00
|
|
|
|
programs that includes the examples and tests. You must still build
|
2014-02-04 16:14:44 -08:00
|
|
|
|
the actual debug version of the code by typing
|
2010-03-19 15:54:01 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
::
|
|
|
|
|
|
|
2013-07-17 17:09:36 -07:00
|
|
|
|
$ ./waf
|
2010-03-19 15:54:01 -07:00
|
|
|
|
|
2011-01-02 22:57:32 -08:00
|
|
|
|
Now, if you run the ``hello-simulator`` program, you should see the
|
2010-03-19 15:54:01 -07:00
|
|
|
|
expected output.
|
|
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
Program Arguments
|
|
|
|
|
|
+++++++++++++++++
|
|
|
|
|
|
|
|
|
|
|
|
To feed command line arguments to an |ns3| program use this pattern::
|
|
|
|
|
|
|
|
|
|
|
|
$ ./waf --run <ns3-program> --command-template="%s <args>"
|
|
|
|
|
|
|
|
|
|
|
|
Substitute your program name for ``<ns3-program>``, and the arguments
|
|
|
|
|
|
for ``<args>``. The ``--command-template`` argument to Waf is
|
|
|
|
|
|
basically a recipe for constructing the actual command line Waf should use
|
|
|
|
|
|
to execute the program. Waf checks that the build is complete,
|
|
|
|
|
|
sets the shared library paths, then invokes the executable
|
|
|
|
|
|
using the provided command line template,
|
|
|
|
|
|
inserting the program name for the ``%s`` placeholder.
|
|
|
|
|
|
(I admit this is a bit awkward, but that's the way it is. Patches welcome!)
|
|
|
|
|
|
|
2015-01-06 16:51:29 +01:00
|
|
|
|
Another particularly useful example is to run a test suite by itself.
|
|
|
|
|
|
Let's assume that a ``mytest`` test suite exists (it doesn't).
|
|
|
|
|
|
Above, we used the ``./test.py`` script to run a whole slew of
|
2014-02-04 16:14:44 -08:00
|
|
|
|
tests in parallel, by repeatedly invoking the real testing program,
|
|
|
|
|
|
``test-runner``. To invoke ``test-runner`` directly for a single test::
|
|
|
|
|
|
|
2015-01-05 19:43:49 +01:00
|
|
|
|
$ ./waf --run test-runner --command-template="%s --suite=mytest --verbose"
|
2014-02-04 16:14:44 -08:00
|
|
|
|
|
2015-01-06 16:51:29 +01:00
|
|
|
|
This passes the arguments to the ``test-runner`` program.
|
|
|
|
|
|
Since ``mytest`` does not exist, an error message will be generated.
|
|
|
|
|
|
To print the available ``test-runner`` options::
|
2014-02-04 16:14:44 -08:00
|
|
|
|
|
2015-01-05 19:43:49 +01:00
|
|
|
|
$ ./waf --run test-runner --command-template="%s --help"
|
2014-02-04 16:14:44 -08:00
|
|
|
|
|
|
|
|
|
|
Debugging
|
|
|
|
|
|
+++++++++
|
|
|
|
|
|
|
|
|
|
|
|
To run |ns3| programs under the control of another utility, such as
|
|
|
|
|
|
a debugger (*e.g.* ``gdb``) or memory checker (*e.g.* ``valgrind``),
|
|
|
|
|
|
you use a similar ``--command-template="..."`` form.
|
|
|
|
|
|
|
2015-01-06 16:51:29 +01:00
|
|
|
|
For example, to run your |ns3| program ``hello-simulator`` with the arguments
|
2014-02-04 16:14:44 -08:00
|
|
|
|
``<args>`` under the ``gdb`` debugger::
|
|
|
|
|
|
|
|
|
|
|
|
$ ./waf --run=hello-simulator --command-template="gdb %s --args <args>"
|
|
|
|
|
|
|
|
|
|
|
|
Notice that the |ns3| program name goes with the ``--run`` argument,
|
|
|
|
|
|
and the control utility (here ``gdb``) is the first token
|
|
|
|
|
|
in the ``--commmand-template`` argument. The ``--args`` tells ``gdb``
|
|
|
|
|
|
that the remainder of the command line belongs to the "inferior" program.
|
|
|
|
|
|
(Some ``gdb``'s don't understand the ``--args`` feature. In this case,
|
|
|
|
|
|
omit the program arguments from the ``--command-template``,
|
|
|
|
|
|
and use the ``gdb`` command ``set args``.)
|
|
|
|
|
|
|
|
|
|
|
|
We can combine this recipe and the previous one to run a test under the
|
|
|
|
|
|
debugger::
|
|
|
|
|
|
|
|
|
|
|
|
$ ./waf --run test-runner --command-template="gdb %s --args --suite=mytest --verbose"
|
|
|
|
|
|
|
|
|
|
|
|
Working Directory
|
|
|
|
|
|
+++++++++++++++++
|
|
|
|
|
|
|
2015-02-06 06:50:48 -08:00
|
|
|
|
Waf needs to run from its location at the top of the |ns3| tree.
|
2014-02-04 16:14:44 -08:00
|
|
|
|
This becomes the working directory where output files will be written.
|
|
|
|
|
|
But what if you want to keep those ouf to the |ns3| source tree? Use
|
|
|
|
|
|
the ``--cwd`` argument::
|
|
|
|
|
|
|
|
|
|
|
|
$ ./waf --cwd=...
|
|
|
|
|
|
|
|
|
|
|
|
It may be more convenient to start with your working directory where
|
|
|
|
|
|
you want the output files, in which case a little indirection can help::
|
|
|
|
|
|
|
|
|
|
|
|
$ function waff {
|
|
|
|
|
|
CWD="$PWD"
|
|
|
|
|
|
cd $NS3DIR >/dev/null
|
|
|
|
|
|
./waf --cwd="$CWD" $*
|
|
|
|
|
|
cd - >/dev/null
|
|
|
|
|
|
}
|
2008-06-28 19:46:55 -07:00
|
|
|
|
|
2014-02-04 16:14:44 -08:00
|
|
|
|
This embellishment of the previous version saves the current working directory,
|
|
|
|
|
|
``cd``'s to the Waf directory, then instructs Waf to change the working
|
|
|
|
|
|
directory *back* to the saved current working directory before running the
|
|
|
|
|
|
program.
|