blob: a55acf2ad89f4b38ec292983201a2adaf508d898 [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 Afanasyev8e60bcd2015-01-15 20:55:40 +000010ndnSIM 2.0 has been successfully compiled and used on following platforms:
11
12- Ubuntu Linux 12.04 (see the note)
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070013- Ubuntu Linux 14.04 (32- and 64-bit platform)
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070014- Ubuntu Linux 16.04 (32- and 64-bit platform)
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070015- OS X 10.9
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000016- OS X 10.10
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070017- OS X 10.11
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000018
19.. note::
20 ndnSIM is currently cannot be compiled on Ubuntu Linux 12.04 with the packaged boost
21 libraries (there is an `issue with boost 1.48 and gcc 4.6
22 <https://svn.boost.org/trac/boost/ticket/6153>`_). It is still possible to compile ndnSIM
23 on this platform, but either compiler or boost libraries (or both) need to get upgraded.
24
25 More recent version of boost can be installed from "Boost C++ Libraries" team PPA::
26
27 sudo apt-get install python-software-properties
28 sudo add-apt-repository ppa:boost-latest/ppa
29 sudo apt-get update
30 sudo apt-get install libboost1.55-all-dev
31
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070032 # add --boost-libs=/usr/lib/x86_64-linux-gnu to ./waf configure
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000033 # ./waf configure --boost-libs=/usr/lib/x86_64-linux-gnu
34
35 Make sure that all other version of boost libraries (``-dev`` packages) are removed,
36 otherwise compilation will fail.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080037
38.. _requirements:
39
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080040Prerequisites
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080041-------------
42
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070043**1. Core dependencies**
44
45- ``python`` >= 2.6
46- ``libsqlite3``
47- ``libcrypto++``
48- ``pkg-config``
49- Boost libraries >= 1.49
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080050
Alexander Afanasyev26b558b2012-12-13 11:39:46 -080051.. role:: red
52
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080053.. note::
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -080054 If you do not have root permissions to install boost, you can install it in your home
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080055 folder. However, you need to be make sure that `libboost_iostreams` library is successfully
56 compiled and is installed. Please refer to :ref:`the following example <Installing boost
57 libraries>` for the hints how to successfully compile and install boost libraries on Ubuntu
58 Linux.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080059
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070060Following are the detailed steps for each platform to install the compiler, all necessary
61development tools and libraries, and ndn-cxx prerequisites.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080062
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070063- OS X
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080064
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070065 * OS X with MacPorts:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080066
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070067 .. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080068
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070069 sudo port install pkgconfig boost sqlite3 libcryptopp
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080070
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070071 * OS X with HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080072
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070073 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080074
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070075 brew install boost cryptopp pkg-config libxml2
76 brew link --force libxml2
Alexander Afanasyev326410e2013-03-09 20:39:11 -080077
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070078- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080079
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070080 * Ubuntu Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080081
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070082 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080083
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070084 sudo apt-get install build-essential libsqlite3-dev libcrypto++-dev
Alexander Afanasyev326410e2013-03-09 20:39:11 -080085
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070086 # For Ubuntu 12.04
87 sudo apt-get install python-software-properties
88 sudo add-apt-repository ppa:boost-latest/ppa
89 sudo apt-get update
90 sudo apt-get install libboost1.55-all-dev
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080091
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070092 # For all other Ubuntu versions
93 sudo apt-get install libboost-all-dev
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080094
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070095 * Fedora Linux
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080096
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070097 .. code-block:: bash
98
99 sudo yum install gcc-g++ git sqlite-devel cryptopp-devel boost-devel
100
101 .. note::
102 :red:`ndnSIM requires boost version at least 1.49.` Many linux distribution
103 (Fedora 16, 17 at the time of this writing) ship an old version of boost, making it
104 impossible to compile ndnSIM out-of-the-box. Please install the latest version, following
105 :ref:`these simple instructions <Installing boost libraries>`.
106
107**2. Dependencies for NS-3 Python bindings**
108
109If you are planning to use NS-3 python bindings, a number of additional dependencies
110should be installed. For example, in order to run `visualizer`_ module, the following
111should be installed:
112
113- OS X
114
115 * OS X with MacPorts:
116
117 .. code-block:: bash
118
119 sudo port install py27-pygraphviz py27-goocanvas
120
121 # If you add NDN macports repository, as described in
122 # http://named-data.net/doc/NFD/current/INSTALL.html#install-nfd-using-the-ndn-macports-repository-on-os-x
123 # you will be able to install another useful python module
124 # sudo port install py27-kiwi
125
126 * OS X with HomeBrew
127
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -0700128 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 -0700129
130- Linux
131
132 * Ubuntu Linux
133
134 .. code-block:: bash
135
136 sudo apt-get install python-dev python-pygraphviz python-kiwi
137 sudo apt-get install python-pygoocanvas python-gnome2
138 sudo apt-get install python-rsvg ipython
139
140 * Fedora Linux
141
142 .. code-block:: bash
143
144 sudo yum install pygoocanvas python-kiwi graphviz-python
145
146 # easy_install method, since pygraphviz is not (yet?) packaged into Fedora (https://bugzilla.redhat.com/show_bug.cgi?id=740687)
147 sudo yum install graphviz-devel
148 sudo yum install python-pip
149 sudo easy_install pygraphviz
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -0800150
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800151.. _visualizer: http://www.nsnam.org/wiki/index.php/PyViz
152
153Downloading ndnSIM source
154-------------------------
155
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800156ndnSIM package consists of three pieces:
157
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800158- a custom branch of NS-3 that contains a few useful patches
159- a customized python binding generation library (necessary if you want to use NS-3's python
160 bindings and/or visualizer module)
161- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700162- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
163 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800164
165The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800166
167.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800168
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800169 mkdir ndnSIM
170 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700171 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
172 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700173 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800174
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700175The last command downloads ndnSIM source code and source code of all submodules (i.e.,
176ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
177versions of submodules can be retrieved using:
178
179.. code-block:: bash
180
181 git submodule update --init
182
183The same command should be run to update submodules when there are new changes available.
184
185.. note::
186 A few modification to the base NS-3 and pybindgen are necessary to run successfully
187 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
188 bugfixes that we are submitting to NS-3 upstream. We also periodically update
189 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
190 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800191
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700192
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800193Compiling and running ndnSIM
194----------------------------
195
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700196ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
197sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800198
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700199.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800200
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700201 cd <ns-3-folder>
202 ./waf configure --enable-examples
203 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800204
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700205On OS X (with MacPorts), you may need to modify the configure command to use MacPorts
206version of python:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800207
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700208.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800209
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700210 cd <ns-3-folder>
211 ./waf configure --with-python=/opt/local/bin/python2.7 --enable-examples
212 # or run ``sudo port select python python27``
213 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800214
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700215.. note::
216 On OS X configuration stage may get :ref:`stuck at detecting gtk module <Problems with
217 the gtk python module on OS X>`. Make sure you have `XQuartz
218 <http://xquartz.macosforge.org>`_ installed or disable python as described in the
219 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800220
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700221Python bindings is an optional and not very stable feature of NS-3 simulator. It is
222possible to disable python bindings compilation either to speed up compilation or to avoid
223certain compilation errors (e.g., "Could not find a task generator for the name
224'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800225
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700226.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800227
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700228 cd <ns-3-folder>
229 ./waf configure --disable-python --enable-examples
230 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800231
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700232For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800233
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800234
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700235Simulating using ndnSIM
236-----------------------
237
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700238- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700239
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700240 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
241 described in :doc:`examples section of this tutorial <examples>`. For example, to run
242 ``ndn-simple.cpp`` scenario, you can run the following command:
243
244 .. code-block:: bash
245
246 ./waf --run=ndn-simple
247
248 To run ``ndn-grid.cpp`` scenario:
249
250 .. code-block:: bash
251
252 ./waf --run=ndn-grid
253
254 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
255 this will work only when NS-3 is compiled in debug mode):
256
257 .. code-block:: bash
258
259 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
260
261 If you have compiled with python bindings, then you can try to run these simulations with
262 visualizer:
263
264 .. code-block:: bash
265
266 ./waf --run=ndn-simple --vis
267
268 or:
269
270 .. code-block:: bash
271
272 ./waf --run=ndn-grid --vis
273
274 .. note::
275 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
276 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800277
278- Real experimentation
279
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700280 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
281
282 Alternative and a recommended way is to write simulation scenarios in a separate
283 repository, not related to either NS-3 or ndnSIM. For example, you can use the
284 following template to write your extensions, simulation scenarios, and metric processing
285 scripts: `<http://github.com/cawka/ndnSIM-scenario-template>`_:
286
287 .. code-block:: bash
288
289 mkdir ndnSIM
290 cd ndnSIM
291 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
292 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
293 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
294
295 # Build and install NS-3 and ndnSIM
296 cd ns-3
297 ./waf configure -d optimized
298 ./waf
299
300 sudo ./waf install
301 cd ..
302
303 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
304 cd scenario
305 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
306 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
307
308 ./waf configure
309
310 ./waf --run <scenario>
311
312 For more detailed information, refer to `README file
313 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800314
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700315..
316 Examples of template-based simulations
317 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800318
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700319 1. ndnSIM examples from `<http://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800320
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700321 - `<http://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700322
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700323 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
324 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 -0700325
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700326 - `<http://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700327
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700328 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
329 Information Dissemination Using Named Data" paper by Wang et
330 al. (`<http://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700331
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700332 - `<http://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700333
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700334 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
335 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700336
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700337 - `<http://github.com/cawka/ndnSIM-sample-topologies>`_, or