blob: aa25b5eb02c76d60080d34b4ed2f3744bed31f1d [file] [log] [blame]
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -08001Getting Started
2===============
3
4Portability
5------------
6
Alexander Afanasyev40b88332019-02-13 16:19:06 -05007.. image:: https://travis-ci.org/named-data-ndnSIM/ndnSIM.svg?branch=master
Alexander Afanasyev5dee3612015-08-25 16:09:04 -07008 :target: https://travis-ci.org/named-data-ndnSIM/ndnSIM
9
Alexander Afanasyev0167d582016-09-08 19:22:08 -070010ndnSIM 2.x has been successfully compiled and used on following platforms:
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000011
Alexander Afanasyev40b88332019-02-13 16:19:06 -050012- Ubuntu Linux 18.04
13- Ubuntu Linux 16.04
Spyridon Mastorakisaf09eac2018-02-22 11:25:26 -080014- macOS 10.13
Alexander Afanasyev40b88332019-02-13 16:19:06 -050015- macOS 10.14
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000016
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080017.. _requirements:
18
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080019Prerequisites
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080020-------------
21
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070022**1. Core dependencies**
23
Alexander Afanasyev40b88332019-02-13 16:19:06 -050024- ``python`` >= 2.7
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070025- ``libsqlite3``
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070026- ``pkg-config``
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080027- ``openssl``
28- Boost libraries >= 1.54
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080029
Alexander Afanasyev26b558b2012-12-13 11:39:46 -080030.. role:: red
31
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080032.. note::
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -080033 If you do not have root permissions to install boost, you can install it in your home
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080034 folder. However, you need to be make sure that `libboost_iostreams` library is successfully
35 compiled and is installed. Please refer to :ref:`the following example <Installing boost
36 libraries>` for the hints how to successfully compile and install boost libraries on Ubuntu
37 Linux.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080038
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070039Following are the detailed steps for each platform to install the compiler, all necessary
40development tools and libraries, and ndn-cxx prerequisites.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080041
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080042- macOS
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080043
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080044 * macOS with HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080045
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070046 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080047
Alexander Afanasyev24810922019-02-10 22:06:43 -050048 brew install boost pkg-config openssl libxml2
49 export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig" # put this line in ~/.bashrc or manually type before ./waf configure
Alexander Afanasyev326410e2013-03-09 20:39:11 -080050
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070051- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080052
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070053 * Ubuntu Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080054
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070055 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080056
Alexander Afanasyev24810922019-02-10 22:06:43 -050057 sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python-setuptools castxml
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080058
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070059 * Fedora Linux
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080060
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070061 .. code-block:: bash
62
Alexander Afanasyev24810922019-02-10 22:06:43 -050063 sudo yum install gcc-g++ git sqlite-devel boost-devel openssl-devel
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070064
65 .. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080066 :red:`ndnSIM requires boost version at least 1.54.` Many linux distribution
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070067 (Fedora 16, 17 at the time of this writing) ship an old version of boost, making it
68 impossible to compile ndnSIM out-of-the-box. Please install the latest version, following
69 :ref:`these simple instructions <Installing boost libraries>`.
70
71**2. Dependencies for NS-3 Python bindings**
72
73If you are planning to use NS-3 python bindings, a number of additional dependencies
74should be installed. For example, in order to run `visualizer`_ module, the following
75should be installed:
76
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080077- macOS
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070078
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080079 * macOS with HomeBrew
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070080
Alexander Afanasyev24810922019-02-10 22:06:43 -050081 .. code-block:: bash
82
83 brew install cairo goocanvas gtk+3 graphviz gobject-introspection castxml
84
85 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig" # this needed only for running the next line
86 pip install pygraphviz pycairo PyGObject pygccxml
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070087
88- Linux
89
90 * Ubuntu Linux
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080091
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070092 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080093
Alexander Afanasyev40b88332019-02-13 16:19:06 -050094 sudo apt install python-dev python-pygraphviz python-kiwi python-gnome2 ipython libcairo2-dev python3-gi libgirepository1.0-dev python-gi python-gi-cairo gir1.2-gtk-3.0 gir1.2-goocanvas-2.0 python-pip
95 sudo pip install pygraphviz pycairo PyGObject pygccxml
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080096
Alexander Afanasyev24810922019-02-10 22:06:43 -050097.. _visualizer: https://www.nsnam.org/wiki/PyViz
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080098
99Downloading ndnSIM source
100-------------------------
101
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800102ndnSIM package consists of three pieces:
103
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800104- a custom branch of NS-3 that contains a few useful patches
105- a customized python binding generation library (necessary if you want to use NS-3's python
106 bindings and/or visualizer module)
107- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700108- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
109 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800110
111The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800112
113.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800114
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800115 mkdir ndnSIM
116 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700117 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
118 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700119 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800120
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700121The last command downloads ndnSIM source code and source code of all submodules (i.e.,
122ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
123versions of submodules can be retrieved using:
124
125.. code-block:: bash
126
127 git submodule update --init
128
129The same command should be run to update submodules when there are new changes available.
130
131.. note::
132 A few modification to the base NS-3 and pybindgen are necessary to run successfully
133 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
134 bugfixes that we are submitting to NS-3 upstream. We also periodically update
135 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
136 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800137
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700138
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800139Compiling and running ndnSIM
140----------------------------
141
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700142ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
143sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800144
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700145.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800146
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700147 cd <ns-3-folder>
148 ./waf configure --enable-examples
149 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800150
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800151On macOS (with MacPorts), you may need to modify the configure command to use MacPorts
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700152version of python:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800153
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700154.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800155
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700156 cd <ns-3-folder>
157 ./waf configure --with-python=/opt/local/bin/python2.7 --enable-examples
158 # or run ``sudo port select python python27``
159 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800160
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700161.. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800162 On macOS configuration stage may get :ref:`stuck at detecting gtk module <Problems with
163 the gtk python module on macOS>`. Make sure you have `XQuartz
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700164 <http://xquartz.macosforge.org>`_ installed or disable python as described in the
165 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800166
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700167Python bindings is an optional and not very stable feature of NS-3 simulator. It is
168possible to disable python bindings compilation either to speed up compilation or to avoid
169certain compilation errors (e.g., "Could not find a task generator for the name
170'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800171
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700172.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800173
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700174 cd <ns-3-folder>
175 ./waf configure --disable-python --enable-examples
176 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800177
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700178For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800179
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800180
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700181Simulating using ndnSIM
182-----------------------
183
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700184- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700185
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700186 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
187 described in :doc:`examples section of this tutorial <examples>`. For example, to run
188 ``ndn-simple.cpp`` scenario, you can run the following command:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800189
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700190 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800191
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700192 ./waf --run=ndn-simple
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800193
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700194 To run ``ndn-grid.cpp`` scenario:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800195
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700196 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800197
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700198 ./waf --run=ndn-grid
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800199
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700200 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
201 this will work only when NS-3 is compiled in debug mode):
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800202
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700203 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800204
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700205 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800206
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700207 If you have compiled with python bindings, then you can try to run these simulations with
208 visualizer:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800209
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700210 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800211
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700212 ./waf --run=ndn-simple --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800213
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700214 or:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800215
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700216 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800217
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700218 ./waf --run=ndn-grid --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800219
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700220 .. note::
221 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
222 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800223
224- Real experimentation
225
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700226 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800227
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700228 Alternative and a recommended way is to write simulation scenarios in a separate
229 repository, not related to either NS-3 or ndnSIM. For example, you can use the
230 following template to write your extensions, simulation scenarios, and metric processing
231 scripts: `<http://github.com/cawka/ndnSIM-scenario-template>`_:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800232
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700233 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800234
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700235 mkdir ndnSIM
236 cd ndnSIM
237 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
238 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
239 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800240
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700241 # Build and install NS-3 and ndnSIM
242 cd ns-3
243 ./waf configure -d optimized
244 ./waf
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800245
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700246 sudo ./waf install
247 cd ..
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800248
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700249 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
250 cd scenario
251 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
252 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800253
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700254 ./waf configure
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800255
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700256 ./waf --run <scenario>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800257
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700258 For more detailed information, refer to `README file
259 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800260
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700261..
262 Examples of template-based simulations
263 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800264
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700265 1. ndnSIM examples from `<http://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800266
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700267 - `<http://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700268
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700269 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
270 Forwarding Plane" paper by Yi et al. (`<http://dx.doi.org/10.1016/j.comcom.2013.01.005>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700271
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700272 - `<http://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700273
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700274 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
275 Information Dissemination Using Named Data" paper by Wang et
276 al. (`<http://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700277
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700278 - `<http://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700279
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700280 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
281 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700282
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700283 - `<http://github.com/cawka/ndnSIM-sample-topologies>`_, or