blob: 782ccded733229fbc7304f69b547c7d489bfe86f [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 Mastorakisaf09eac2018-02-22 11:25:26 -080013- Ubuntu Linux 17.10 (64-bit platform)
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080014- macOS 10.11
15- macOS 10.12
Spyridon Mastorakisaf09eac2018-02-22 11:25:26 -080016- macOS 10.13
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``
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080029- ``openssl``
30- Boost libraries >= 1.54
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080031
Alexander Afanasyev26b558b2012-12-13 11:39:46 -080032.. role:: red
33
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080034.. note::
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -080035 If you do not have root permissions to install boost, you can install it in your home
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080036 folder. However, you need to be make sure that `libboost_iostreams` library is successfully
37 compiled and is installed. Please refer to :ref:`the following example <Installing boost
38 libraries>` for the hints how to successfully compile and install boost libraries on Ubuntu
39 Linux.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080040
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070041Following are the detailed steps for each platform to install the compiler, all necessary
42development tools and libraries, and ndn-cxx prerequisites.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080043
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080044- macOS
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080045
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080046 * macOS with MacPorts:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080047
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070048 .. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080049
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080050 sudo port install pkgconfig boost sqlite3 libcryptopp openssl
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080051
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080052 * macOS with HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080053
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070054 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080055
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080056 brew install boost cryptopp pkg-config openssl libxml2
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070057 brew link --force libxml2
Alexander Afanasyev326410e2013-03-09 20:39:11 -080058
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070059- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080060
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070061 * Ubuntu Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080062
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070063 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080064
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080065 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 -080066
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070067 * Fedora Linux
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080068
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070069 .. code-block:: bash
70
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080071 sudo yum install gcc-g++ git sqlite-devel cryptopp-devel boost-devel openssl-devel
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070072
73 .. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080074 :red:`ndnSIM requires boost version at least 1.54.` Many linux distribution
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070075 (Fedora 16, 17 at the time of this writing) ship an old version of boost, making it
76 impossible to compile ndnSIM out-of-the-box. Please install the latest version, following
77 :ref:`these simple instructions <Installing boost libraries>`.
78
79**2. Dependencies for NS-3 Python bindings**
80
81If you are planning to use NS-3 python bindings, a number of additional dependencies
82should be installed. For example, in order to run `visualizer`_ module, the following
83should be installed:
84
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080085- macOS
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070086
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080087 * macOS with MacPorts:
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070088
89 .. code-block:: bash
90
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080091 sudo port install py27-pygraphviz py27-goocanvas py27-kiwi
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070092
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080093 * macOS with HomeBrew
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070094
Alexander Afanasyevb4cf1792016-06-26 21:16:24 -070095 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 -070096
97- Linux
98
99 * Ubuntu Linux
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800100
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700101 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800102
103 sudo apt-get install python-dev python-pygraphviz python-kiwi python-pygoocanvas python-gnome2 python-rsvg ipython
104
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700105 * Fedora Linux
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800106
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700107 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800108
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700109 sudo yum install pygoocanvas python-kiwi graphviz-python
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800110
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700111 # easy_install method, since pygraphviz is not (yet?) packaged into Fedora (https://bugzilla.redhat.com/show_bug.cgi?id=740687)
112 sudo yum install graphviz-devel
113 sudo yum install python-pip
114 sudo easy_install pygraphviz
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -0800115
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800116.. _visualizer: http://www.nsnam.org/wiki/index.php/PyViz
117
118Downloading ndnSIM source
119-------------------------
120
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800121ndnSIM package consists of three pieces:
122
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800123- a custom branch of NS-3 that contains a few useful patches
124- a customized python binding generation library (necessary if you want to use NS-3's python
125 bindings and/or visualizer module)
126- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700127- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
128 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800129
130The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800131
132.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800133
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800134 mkdir ndnSIM
135 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700136 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
137 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700138 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800139
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700140The last command downloads ndnSIM source code and source code of all submodules (i.e.,
141ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
142versions of submodules can be retrieved using:
143
144.. code-block:: bash
145
146 git submodule update --init
147
148The same command should be run to update submodules when there are new changes available.
149
150.. note::
151 A few modification to the base NS-3 and pybindgen are necessary to run successfully
152 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
153 bugfixes that we are submitting to NS-3 upstream. We also periodically update
154 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
155 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800156
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700157
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800158Compiling and running ndnSIM
159----------------------------
160
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700161ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
162sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800163
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700164.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800165
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700166 cd <ns-3-folder>
167 ./waf configure --enable-examples
168 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800169
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800170On macOS (with MacPorts), you may need to modify the configure command to use MacPorts
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700171version of python:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800172
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700173.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800174
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700175 cd <ns-3-folder>
176 ./waf configure --with-python=/opt/local/bin/python2.7 --enable-examples
177 # or run ``sudo port select python python27``
178 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800179
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700180.. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800181 On macOS configuration stage may get :ref:`stuck at detecting gtk module <Problems with
182 the gtk python module on macOS>`. Make sure you have `XQuartz
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700183 <http://xquartz.macosforge.org>`_ installed or disable python as described in the
184 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800185
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700186Python bindings is an optional and not very stable feature of NS-3 simulator. It is
187possible to disable python bindings compilation either to speed up compilation or to avoid
188certain compilation errors (e.g., "Could not find a task generator for the name
189'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800190
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700191.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800192
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700193 cd <ns-3-folder>
194 ./waf configure --disable-python --enable-examples
195 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800196
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700197For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800198
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800199
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700200Simulating using ndnSIM
201-----------------------
202
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700203- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700204
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700205 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
206 described in :doc:`examples section of this tutorial <examples>`. For example, to run
207 ``ndn-simple.cpp`` scenario, you can run the following command:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800208
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700209 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800210
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700211 ./waf --run=ndn-simple
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800212
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700213 To run ``ndn-grid.cpp`` scenario:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800214
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700215 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800216
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700217 ./waf --run=ndn-grid
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800218
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700219 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
220 this will work only when NS-3 is compiled in debug mode):
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800221
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700222 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800223
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700224 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800225
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700226 If you have compiled with python bindings, then you can try to run these simulations with
227 visualizer:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800228
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700229 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800230
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700231 ./waf --run=ndn-simple --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800232
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700233 or:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800234
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700235 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800236
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700237 ./waf --run=ndn-grid --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800238
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700239 .. note::
240 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
241 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800242
243- Real experimentation
244
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700245 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800246
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700247 Alternative and a recommended way is to write simulation scenarios in a separate
248 repository, not related to either NS-3 or ndnSIM. For example, you can use the
249 following template to write your extensions, simulation scenarios, and metric processing
250 scripts: `<http://github.com/cawka/ndnSIM-scenario-template>`_:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800251
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700252 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800253
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700254 mkdir ndnSIM
255 cd ndnSIM
256 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
257 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
258 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800259
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700260 # Build and install NS-3 and ndnSIM
261 cd ns-3
262 ./waf configure -d optimized
263 ./waf
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800264
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700265 sudo ./waf install
266 cd ..
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800267
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700268 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
269 cd scenario
270 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
271 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800272
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700273 ./waf configure
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800274
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700275 ./waf --run <scenario>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800276
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700277 For more detailed information, refer to `README file
278 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800279
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700280..
281 Examples of template-based simulations
282 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800283
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700284 1. ndnSIM examples from `<http://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800285
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700286 - `<http://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700287
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700288 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
289 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 -0700290
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700291 - `<http://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700292
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700293 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
294 Information Dissemination Using Named Data" paper by Wang et
295 al. (`<http://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700296
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700297 - `<http://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700298
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700299 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
300 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700301
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700302 - `<http://github.com/cawka/ndnSIM-sample-topologies>`_, or