blob: 03c6aea5380ab155bded6fab2ba25c3fd8ea5925 [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)
14- Ubuntu Linux 15.05 (64-bit platform)
15- OS X 10.9
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000016- OS X 10.10
17
18.. note::
19 ndnSIM is currently cannot be compiled on Ubuntu Linux 12.04 with the packaged boost
20 libraries (there is an `issue with boost 1.48 and gcc 4.6
21 <https://svn.boost.org/trac/boost/ticket/6153>`_). It is still possible to compile ndnSIM
22 on this platform, but either compiler or boost libraries (or both) need to get upgraded.
23
24 More recent version of boost can be installed from "Boost C++ Libraries" team PPA::
25
26 sudo apt-get install python-software-properties
27 sudo add-apt-repository ppa:boost-latest/ppa
28 sudo apt-get update
29 sudo apt-get install libboost1.55-all-dev
30
Spyridon Mastorakisf542c0b2015-08-11 22:59:18 -070031 # add --boost-libs=/usr/lib/x86_64-linux-gnu to ./waf configure
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000032 # ./waf configure --boost-libs=/usr/lib/x86_64-linux-gnu
33
34 Make sure that all other version of boost libraries (``-dev`` packages) are removed,
35 otherwise compilation will fail.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080036
37.. _requirements:
38
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080039Prerequisites
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080040-------------
41
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070042**1. Core dependencies**
43
44- ``python`` >= 2.6
45- ``libsqlite3``
46- ``libcrypto++``
47- ``pkg-config``
48- Boost libraries >= 1.49
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080049
Alexander Afanasyev26b558b2012-12-13 11:39:46 -080050.. role:: red
51
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080052.. note::
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -080053 If you do not have root permissions to install boost, you can install it in your home
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080054 folder. However, you need to be make sure that `libboost_iostreams` library is successfully
55 compiled and is installed. Please refer to :ref:`the following example <Installing boost
56 libraries>` for the hints how to successfully compile and install boost libraries on Ubuntu
57 Linux.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080058
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070059Following are the detailed steps for each platform to install the compiler, all necessary
60development tools and libraries, and ndn-cxx prerequisites.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080061
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070062- OS X
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080063
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070064 * OS X with MacPorts:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080065
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070066 .. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080067
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070068 sudo port install pkgconfig boost sqlite3 libcryptopp
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080069
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070070 * OS X with HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080071
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070072 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080073
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070074 brew install pkg-config boost cryptopp
Alexander Afanasyev326410e2013-03-09 20:39:11 -080075
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070076- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080077
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070078 * Ubuntu Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080079
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070080 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080081
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070082 sudo apt-get install build-essential libsqlite3-dev libcrypto++-dev
Alexander Afanasyev326410e2013-03-09 20:39:11 -080083
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070084 # For Ubuntu 12.04
85 sudo apt-get install python-software-properties
86 sudo add-apt-repository ppa:boost-latest/ppa
87 sudo apt-get update
88 sudo apt-get install libboost1.55-all-dev
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080089
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070090 # For all other Ubuntu versions
91 sudo apt-get install libboost-all-dev
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080092
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070093 * Fedora Linux
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080094
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070095 .. code-block:: bash
96
97 sudo yum install gcc-g++ git sqlite-devel cryptopp-devel boost-devel
98
99 .. note::
100 :red:`ndnSIM requires boost version at least 1.49.` Many linux distribution
101 (Fedora 16, 17 at the time of this writing) ship an old version of boost, making it
102 impossible to compile ndnSIM out-of-the-box. Please install the latest version, following
103 :ref:`these simple instructions <Installing boost libraries>`.
104
105**2. Dependencies for NS-3 Python bindings**
106
107If you are planning to use NS-3 python bindings, a number of additional dependencies
108should be installed. For example, in order to run `visualizer`_ module, the following
109should be installed:
110
111- OS X
112
113 * OS X with MacPorts:
114
115 .. code-block:: bash
116
117 sudo port install py27-pygraphviz py27-goocanvas
118
119 # If you add NDN macports repository, as described in
120 # http://named-data.net/doc/NFD/current/INSTALL.html#install-nfd-using-the-ndn-macports-repository-on-os-x
121 # you will be able to install another useful python module
122 # sudo port install py27-kiwi
123
124 * OS X with HomeBrew
125
126 .. code-block:: bash
127
128 brew install boost cryptopp pkg-config libxml2
129 brew link --force libxml2
130
131- Linux
132
133 * Ubuntu Linux
134
135 .. code-block:: bash
136
137 sudo apt-get install python-dev python-pygraphviz python-kiwi
138 sudo apt-get install python-pygoocanvas python-gnome2
139 sudo apt-get install python-rsvg ipython
140
141 * Fedora Linux
142
143 .. code-block:: bash
144
145 sudo yum install pygoocanvas python-kiwi graphviz-python
146
147 # easy_install method, since pygraphviz is not (yet?) packaged into Fedora (https://bugzilla.redhat.com/show_bug.cgi?id=740687)
148 sudo yum install graphviz-devel
149 sudo yum install python-pip
150 sudo easy_install pygraphviz
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -0800151
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800152.. _visualizer: http://www.nsnam.org/wiki/index.php/PyViz
153
154Downloading ndnSIM source
155-------------------------
156
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800157ndnSIM package consists of three pieces:
158
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800159- a custom branch of NS-3 that contains a few useful patches
160- a customized python binding generation library (necessary if you want to use NS-3's python
161 bindings and/or visualizer module)
162- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700163- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
164 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800165
166The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800167
168.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800169
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800170 mkdir ndnSIM
171 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700172 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
173 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700174 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800175
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700176The last command downloads ndnSIM source code and source code of all submodules (i.e.,
177ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
178versions of submodules can be retrieved using:
179
180.. code-block:: bash
181
182 git submodule update --init
183
184The same command should be run to update submodules when there are new changes available.
185
186.. note::
187 A few modification to the base NS-3 and pybindgen are necessary to run successfully
188 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
189 bugfixes that we are submitting to NS-3 upstream. We also periodically update
190 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
191 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800192
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700193
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800194Compiling and running ndnSIM
195----------------------------
196
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700197ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
198sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800199
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700200.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800201
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700202 cd <ns-3-folder>
203 ./waf configure --enable-examples
204 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800205
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700206On OS X (with MacPorts), you may need to modify the configure command to use MacPorts
207version of python:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800208
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700209.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800210
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700211 cd <ns-3-folder>
212 ./waf configure --with-python=/opt/local/bin/python2.7 --enable-examples
213 # or run ``sudo port select python python27``
214 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800215
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700216.. note::
217 On OS X configuration stage may get :ref:`stuck at detecting gtk module <Problems with
218 the gtk python module on OS X>`. Make sure you have `XQuartz
219 <http://xquartz.macosforge.org>`_ installed or disable python as described in the
220 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800221
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700222Python bindings is an optional and not very stable feature of NS-3 simulator. It is
223possible to disable python bindings compilation either to speed up compilation or to avoid
224certain compilation errors (e.g., "Could not find a task generator for the name
225'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800226
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700227.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800228
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700229 cd <ns-3-folder>
230 ./waf configure --disable-python --enable-examples
231 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800232
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700233For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800234
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800235
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700236Simulating using ndnSIM
237-----------------------
238
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700239- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700240
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700241 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
242 described in :doc:`examples section of this tutorial <examples>`. For example, to run
243 ``ndn-simple.cpp`` scenario, you can run the following command:
244
245 .. code-block:: bash
246
247 ./waf --run=ndn-simple
248
249 To run ``ndn-grid.cpp`` scenario:
250
251 .. code-block:: bash
252
253 ./waf --run=ndn-grid
254
255 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
256 this will work only when NS-3 is compiled in debug mode):
257
258 .. code-block:: bash
259
260 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
261
262 If you have compiled with python bindings, then you can try to run these simulations with
263 visualizer:
264
265 .. code-block:: bash
266
267 ./waf --run=ndn-simple --vis
268
269 or:
270
271 .. code-block:: bash
272
273 ./waf --run=ndn-grid --vis
274
275 .. note::
276 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
277 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800278
279- Real experimentation
280
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700281 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
282
283 Alternative and a recommended way is to write simulation scenarios in a separate
284 repository, not related to either NS-3 or ndnSIM. For example, you can use the
285 following template to write your extensions, simulation scenarios, and metric processing
286 scripts: `<http://github.com/cawka/ndnSIM-scenario-template>`_:
287
288 .. code-block:: bash
289
290 mkdir ndnSIM
291 cd ndnSIM
292 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
293 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
294 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
295
296 # Build and install NS-3 and ndnSIM
297 cd ns-3
298 ./waf configure -d optimized
299 ./waf
300
301 sudo ./waf install
302 cd ..
303
304 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
305 cd scenario
306 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
307 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
308
309 ./waf configure
310
311 ./waf --run <scenario>
312
313 For more detailed information, refer to `README file
314 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800315
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700316..
317 Examples of template-based simulations
318 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800319
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700320 1. ndnSIM examples from `<http://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800321
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700322 - `<http://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700323
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700324 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
325 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 -0700326
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700327 - `<http://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700328
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700329 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
330 Information Dissemination Using Named Data" paper by Wang et
331 al. (`<http://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700332
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700333 - `<http://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700334
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700335 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
336 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700337
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700338 - `<http://github.com/cawka/ndnSIM-sample-topologies>`_, or