blob: 802daa227e129af12e33d4d3d41249703216cb37 [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 Afanasyev5dee3612015-08-25 16:09:04 -070012- Ubuntu Linux 14.04 (32- and 64-bit platform)
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070013- Ubuntu Linux 16.04 (32- and 64-bit platform)
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070014- OS X 10.9
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000015- OS X 10.10
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070016- OS X 10.11
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000017
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080018.. _requirements:
19
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080020Prerequisites
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080021-------------
22
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070023**1. Core dependencies**
24
25- ``python`` >= 2.6
26- ``libsqlite3``
27- ``libcrypto++``
28- ``pkg-config``
Alexander Afanasyev0167d582016-09-08 19:22:08 -070029- Boost libraries >= 1.53
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
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070043- OS X
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080044
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070045 * OS X 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
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070049 sudo port install pkgconfig boost sqlite3 libcryptopp
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080050
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070051 * OS X 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
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070055 brew install boost cryptopp pkg-config libxml2
56 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
Alexander Afanasyev0167d582016-09-08 19:22:08 -070064 sudo apt-get install build-essential libsqlite3-dev libcrypto++-dev libboost-all-dev
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
70 sudo yum install gcc-g++ git sqlite-devel cryptopp-devel boost-devel
71
72 .. note::
73 :red:`ndnSIM requires boost version at least 1.49.` Many linux distribution
74 (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
84- OS X
85
86 * OS X with MacPorts:
87
88 .. code-block:: bash
89
90 sudo port install py27-pygraphviz py27-goocanvas
91
92 # If you add NDN macports repository, as described in
93 # http://named-data.net/doc/NFD/current/INSTALL.html#install-nfd-using-the-ndn-macports-repository-on-os-x
94 # you will be able to install another useful python module
95 # sudo port install py27-kiwi
96
97 * OS X with HomeBrew
98
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070099 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 -0700100
101- Linux
102
103 * Ubuntu Linux
104
105 .. code-block:: bash
106
107 sudo apt-get install python-dev python-pygraphviz python-kiwi
108 sudo apt-get install python-pygoocanvas python-gnome2
109 sudo apt-get install python-rsvg ipython
110
111 * Fedora Linux
112
113 .. code-block:: bash
114
115 sudo yum install pygoocanvas python-kiwi graphviz-python
116
117 # easy_install method, since pygraphviz is not (yet?) packaged into Fedora (https://bugzilla.redhat.com/show_bug.cgi?id=740687)
118 sudo yum install graphviz-devel
119 sudo yum install python-pip
120 sudo easy_install pygraphviz
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -0800121
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800122.. _visualizer: http://www.nsnam.org/wiki/index.php/PyViz
123
124Downloading ndnSIM source
125-------------------------
126
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800127ndnSIM package consists of three pieces:
128
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800129- a custom branch of NS-3 that contains a few useful patches
130- a customized python binding generation library (necessary if you want to use NS-3's python
131 bindings and/or visualizer module)
132- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700133- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
134 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800135
136The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800137
138.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800139
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800140 mkdir ndnSIM
141 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700142 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
143 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700144 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800145
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700146The last command downloads ndnSIM source code and source code of all submodules (i.e.,
147ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
148versions of submodules can be retrieved using:
149
150.. code-block:: bash
151
152 git submodule update --init
153
154The same command should be run to update submodules when there are new changes available.
155
156.. note::
157 A few modification to the base NS-3 and pybindgen are necessary to run successfully
158 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
159 bugfixes that we are submitting to NS-3 upstream. We also periodically update
160 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
161 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800162
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700163
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800164Compiling and running ndnSIM
165----------------------------
166
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700167ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
168sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800169
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700170.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800171
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700172 cd <ns-3-folder>
173 ./waf configure --enable-examples
174 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800175
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700176On OS X (with MacPorts), you may need to modify the configure command to use MacPorts
177version of python:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800178
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700179.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800180
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700181 cd <ns-3-folder>
182 ./waf configure --with-python=/opt/local/bin/python2.7 --enable-examples
183 # or run ``sudo port select python python27``
184 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800185
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700186.. note::
187 On OS X configuration stage may get :ref:`stuck at detecting gtk module <Problems with
188 the gtk python module on OS X>`. Make sure you have `XQuartz
189 <http://xquartz.macosforge.org>`_ installed or disable python as described in the
190 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800191
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700192Python bindings is an optional and not very stable feature of NS-3 simulator. It is
193possible to disable python bindings compilation either to speed up compilation or to avoid
194certain compilation errors (e.g., "Could not find a task generator for the name
195'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800196
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700197.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800198
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700199 cd <ns-3-folder>
200 ./waf configure --disable-python --enable-examples
201 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800202
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700203For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800204
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800205
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700206Simulating using ndnSIM
207-----------------------
208
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700209- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700210
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700211 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
212 described in :doc:`examples section of this tutorial <examples>`. For example, to run
213 ``ndn-simple.cpp`` scenario, you can run the following command:
214
215 .. code-block:: bash
216
217 ./waf --run=ndn-simple
218
219 To run ``ndn-grid.cpp`` scenario:
220
221 .. code-block:: bash
222
223 ./waf --run=ndn-grid
224
225 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
226 this will work only when NS-3 is compiled in debug mode):
227
228 .. code-block:: bash
229
230 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
231
232 If you have compiled with python bindings, then you can try to run these simulations with
233 visualizer:
234
235 .. code-block:: bash
236
237 ./waf --run=ndn-simple --vis
238
239 or:
240
241 .. code-block:: bash
242
243 ./waf --run=ndn-grid --vis
244
245 .. note::
246 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
247 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800248
249- Real experimentation
250
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700251 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
252
253 Alternative and a recommended way is to write simulation scenarios in a separate
254 repository, not related to either NS-3 or ndnSIM. For example, you can use the
255 following template to write your extensions, simulation scenarios, and metric processing
256 scripts: `<http://github.com/cawka/ndnSIM-scenario-template>`_:
257
258 .. code-block:: bash
259
260 mkdir ndnSIM
261 cd ndnSIM
262 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
263 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
264 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
265
266 # Build and install NS-3 and ndnSIM
267 cd ns-3
268 ./waf configure -d optimized
269 ./waf
270
271 sudo ./waf install
272 cd ..
273
274 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
275 cd scenario
276 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
277 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
278
279 ./waf configure
280
281 ./waf --run <scenario>
282
283 For more detailed information, refer to `README file
284 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800285
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700286..
287 Examples of template-based simulations
288 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800289
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700290 1. ndnSIM examples from `<http://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800291
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700292 - `<http://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700293
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700294 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
295 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 -0700296
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700297 - `<http://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700298
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700299 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
300 Information Dissemination Using Named Data" paper by Wang et
301 al. (`<http://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700302
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700303 - `<http://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700304
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700305 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
306 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700307
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700308 - `<http://github.com/cawka/ndnSIM-sample-topologies>`_, or