blob: 3b74f6899985eb070a44631fefe081a2862d30b5 [file] [log] [blame]
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -08001Getting Started
2===============
3
4Portability
5------------
6
Alexander Afanasyev5dee3612015-08-25 16:09:04 -07007.. image:: https://travis-ci.org/named-data-ndnSIM/ndnSIM.svg?branch=test-travis-ci
8 :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 Afanasyevb4cf1792016-06-26 21:16:24 -070012- Ubuntu Linux 16.04 (32- and 64-bit platform)
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080013- macOS 10.10
14- macOS 10.11
15- macOS 10.12
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
24- ``python`` >= 2.6
25- ``libsqlite3``
26- ``libcrypto++``
27- ``pkg-config``
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080028- ``openssl``
29- Boost libraries >= 1.54
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080030
Alexander Afanasyev26b558b2012-12-13 11:39:46 -080031.. role:: red
32
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080033.. note::
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -080034 If you do not have root permissions to install boost, you can install it in your home
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080035 folder. However, you need to be make sure that `libboost_iostreams` library is successfully
36 compiled and is installed. Please refer to :ref:`the following example <Installing boost
37 libraries>` for the hints how to successfully compile and install boost libraries on Ubuntu
38 Linux.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080039
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070040Following are the detailed steps for each platform to install the compiler, all necessary
41development tools and libraries, and ndn-cxx prerequisites.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080042
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080043- macOS
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080044
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080045 * macOS with MacPorts:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080046
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070047 .. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080048
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080049 sudo port install pkgconfig boost sqlite3 libcryptopp openssl
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080050
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080051 * macOS with HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080052
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070053 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080054
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080055 brew install boost cryptopp pkg-config openssl libxml2
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070056 brew link --force libxml2
Alexander Afanasyev326410e2013-03-09 20:39:11 -080057
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070058- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080059
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070060 * Ubuntu Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080061
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070062 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080063
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080064 sudo apt-get install build-essential libsqlite3-dev libcrypto++-dev libboost-all-dev libssl-dev git python-setuptools
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080065
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070066 * Fedora Linux
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080067
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070068 .. code-block:: bash
69
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080070 sudo yum install gcc-g++ git sqlite-devel cryptopp-devel boost-devel openssl-devel
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070071
72 .. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080073 :red:`ndnSIM requires boost version at least 1.54.` Many linux distribution
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070074 (Fedora 16, 17 at the time of this writing) ship an old version of boost, making it
75 impossible to compile ndnSIM out-of-the-box. Please install the latest version, following
76 :ref:`these simple instructions <Installing boost libraries>`.
77
78**2. Dependencies for NS-3 Python bindings**
79
80If you are planning to use NS-3 python bindings, a number of additional dependencies
81should be installed. For example, in order to run `visualizer`_ module, the following
82should be installed:
83
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080084- macOS
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070085
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080086 * macOS with MacPorts:
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070087
88 .. code-block:: bash
89
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080090 sudo port install py27-pygraphviz py27-goocanvas py27-kiwi
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070091
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080092 * macOS with HomeBrew
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070093
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070094 Currently, there are many missing dependencies, so it is impossible to use visualizer module with HomeBrew. Use MacPorts instead.
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070095
96- Linux
97
98 * Ubuntu Linux
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080099
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700100 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800101
102 sudo apt-get install python-dev python-pygraphviz python-kiwi python-pygoocanvas python-gnome2 python-rsvg ipython
103
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700104 * Fedora Linux
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800105
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700106 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800107
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700108 sudo yum install pygoocanvas python-kiwi graphviz-python
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800109
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700110 # easy_install method, since pygraphviz is not (yet?) packaged into Fedora (https://bugzilla.redhat.com/show_bug.cgi?id=740687)
111 sudo yum install graphviz-devel
112 sudo yum install python-pip
113 sudo easy_install pygraphviz
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -0800114
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800115.. _visualizer: http://www.nsnam.org/wiki/index.php/PyViz
116
117Downloading ndnSIM source
118-------------------------
119
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800120ndnSIM package consists of three pieces:
121
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800122- a custom branch of NS-3 that contains a few useful patches
123- a customized python binding generation library (necessary if you want to use NS-3's python
124 bindings and/or visualizer module)
125- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700126- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
127 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800128
129The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800130
131.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800132
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800133 mkdir ndnSIM
134 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700135 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
136 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700137 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800138
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700139The last command downloads ndnSIM source code and source code of all submodules (i.e.,
140ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
141versions of submodules can be retrieved using:
142
143.. code-block:: bash
144
145 git submodule update --init
146
147The same command should be run to update submodules when there are new changes available.
148
149.. note::
150 A few modification to the base NS-3 and pybindgen are necessary to run successfully
151 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
152 bugfixes that we are submitting to NS-3 upstream. We also periodically update
153 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
154 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800155
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700156
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800157Compiling and running ndnSIM
158----------------------------
159
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700160ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
161sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800162
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700163.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800164
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700165 cd <ns-3-folder>
166 ./waf configure --enable-examples
167 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800168
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800169On macOS (with MacPorts), you may need to modify the configure command to use MacPorts
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700170version of python:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -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 --with-python=/opt/local/bin/python2.7 --enable-examples
176 # or run ``sudo port select python python27``
177 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800178
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700179.. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800180 On macOS configuration stage may get :ref:`stuck at detecting gtk module <Problems with
181 the gtk python module on macOS>`. Make sure you have `XQuartz
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700182 <http://xquartz.macosforge.org>`_ installed or disable python as described in the
183 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800184
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700185Python bindings is an optional and not very stable feature of NS-3 simulator. It is
186possible to disable python bindings compilation either to speed up compilation or to avoid
187certain compilation errors (e.g., "Could not find a task generator for the name
188'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800189
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700190.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800191
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700192 cd <ns-3-folder>
193 ./waf configure --disable-python --enable-examples
194 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800195
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700196For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800197
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800198
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700199Simulating using ndnSIM
200-----------------------
201
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700202- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700203
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700204 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
205 described in :doc:`examples section of this tutorial <examples>`. For example, to run
206 ``ndn-simple.cpp`` scenario, you can run the following command:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800207
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700208 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800209
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700210 ./waf --run=ndn-simple
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800211
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700212 To run ``ndn-grid.cpp`` scenario:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800213
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700214 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800215
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700216 ./waf --run=ndn-grid
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800217
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700218 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
219 this will work only when NS-3 is compiled in debug mode):
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800220
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700221 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800222
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700223 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800224
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700225 If you have compiled with python bindings, then you can try to run these simulations with
226 visualizer:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800227
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700228 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800229
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700230 ./waf --run=ndn-simple --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800231
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700232 or:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800233
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700234 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800235
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700236 ./waf --run=ndn-grid --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800237
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700238 .. note::
239 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
240 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800241
242- Real experimentation
243
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700244 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800245
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700246 Alternative and a recommended way is to write simulation scenarios in a separate
247 repository, not related to either NS-3 or ndnSIM. For example, you can use the
248 following template to write your extensions, simulation scenarios, and metric processing
249 scripts: `<http://github.com/cawka/ndnSIM-scenario-template>`_:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800250
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700251 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800252
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700253 mkdir ndnSIM
254 cd ndnSIM
255 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
256 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
257 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800258
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700259 # Build and install NS-3 and ndnSIM
260 cd ns-3
261 ./waf configure -d optimized
262 ./waf
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800263
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700264 sudo ./waf install
265 cd ..
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800266
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700267 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
268 cd scenario
269 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
270 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800271
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700272 ./waf configure
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800273
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700274 ./waf --run <scenario>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800275
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700276 For more detailed information, refer to `README file
277 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800278
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700279..
280 Examples of template-based simulations
281 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800282
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700283 1. ndnSIM examples from `<http://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800284
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700285 - `<http://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700286
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700287 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
288 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 -0700289
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700290 - `<http://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700291
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700292 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
293 Information Dissemination Using Named Data" paper by Wang et
294 al. (`<http://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700295
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700296 - `<http://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700297
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700298 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
299 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700300
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700301 - `<http://github.com/cawka/ndnSIM-sample-topologies>`_, or