blob: 07f295afadbe8c920218dde80182e32426365531 [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``
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070027- ``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 HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080046
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070047 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080048
Alexander Afanasyev24810922019-02-10 22:06:43 -050049 brew install boost pkg-config openssl libxml2
50 export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig" # put this line in ~/.bashrc or manually type before ./waf configure
Alexander Afanasyev326410e2013-03-09 20:39:11 -080051
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070052- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080053
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070054 * Ubuntu Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080055
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070056 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080057
Alexander Afanasyev24810922019-02-10 22:06:43 -050058 sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python-setuptools castxml
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080059
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070060 * Fedora Linux
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080061
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070062 .. code-block:: bash
63
Alexander Afanasyev24810922019-02-10 22:06:43 -050064 sudo yum install gcc-g++ git sqlite-devel boost-devel openssl-devel
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070065
66 .. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080067 :red:`ndnSIM requires boost version at least 1.54.` Many linux distribution
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070068 (Fedora 16, 17 at the time of this writing) ship an old version of boost, making it
69 impossible to compile ndnSIM out-of-the-box. Please install the latest version, following
70 :ref:`these simple instructions <Installing boost libraries>`.
71
72**2. Dependencies for NS-3 Python bindings**
73
74If you are planning to use NS-3 python bindings, a number of additional dependencies
75should be installed. For example, in order to run `visualizer`_ module, the following
76should be installed:
77
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080078- macOS
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070079
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080080 * macOS with HomeBrew
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070081
Alexander Afanasyev24810922019-02-10 22:06:43 -050082 .. code-block:: bash
83
84 brew install cairo goocanvas gtk+3 graphviz gobject-introspection castxml
85
86 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig" # this needed only for running the next line
87 pip install pygraphviz pycairo PyGObject pygccxml
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070088
89- Linux
90
91 * Ubuntu Linux
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080092
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070093 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080094
Alexander Afanasyev24810922019-02-10 22:06:43 -050095 sudo apt install python-dev python-pygraphviz python-kiwi python-pygoocanvas python-gnome2 python-rsvg ipython libcairo2-dev python3-gi libgirepository1.0-dev python-gi python-gi-cairo gir1.2-gtk-3.0 gir1.2-goocanvas-2.0
96 sudo easy_install pip
97 pip install pygraphviz pycairo PyGObject pygccxml
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080098
Alexander Afanasyev24810922019-02-10 22:06:43 -050099.. _visualizer: https://www.nsnam.org/wiki/PyViz
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800100
101Downloading ndnSIM source
102-------------------------
103
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800104ndnSIM package consists of three pieces:
105
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800106- a custom branch of NS-3 that contains a few useful patches
107- a customized python binding generation library (necessary if you want to use NS-3's python
108 bindings and/or visualizer module)
109- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700110- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
111 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800112
113The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800114
115.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800116
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800117 mkdir ndnSIM
118 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700119 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
120 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700121 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800122
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700123The last command downloads ndnSIM source code and source code of all submodules (i.e.,
124ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
125versions of submodules can be retrieved using:
126
127.. code-block:: bash
128
129 git submodule update --init
130
131The same command should be run to update submodules when there are new changes available.
132
133.. note::
134 A few modification to the base NS-3 and pybindgen are necessary to run successfully
135 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
136 bugfixes that we are submitting to NS-3 upstream. We also periodically update
137 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
138 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800139
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700140
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800141Compiling and running ndnSIM
142----------------------------
143
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700144ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
145sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800146
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700147.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800148
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700149 cd <ns-3-folder>
150 ./waf configure --enable-examples
151 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800152
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800153On macOS (with MacPorts), you may need to modify the configure command to use MacPorts
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700154version of python:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800155
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700156.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800157
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700158 cd <ns-3-folder>
159 ./waf configure --with-python=/opt/local/bin/python2.7 --enable-examples
160 # or run ``sudo port select python python27``
161 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800162
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700163.. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800164 On macOS configuration stage may get :ref:`stuck at detecting gtk module <Problems with
165 the gtk python module on macOS>`. Make sure you have `XQuartz
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700166 <http://xquartz.macosforge.org>`_ installed or disable python as described in the
167 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800168
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700169Python bindings is an optional and not very stable feature of NS-3 simulator. It is
170possible to disable python bindings compilation either to speed up compilation or to avoid
171certain compilation errors (e.g., "Could not find a task generator for the name
172'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800173
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700174.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800175
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700176 cd <ns-3-folder>
177 ./waf configure --disable-python --enable-examples
178 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800179
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700180For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800181
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800182
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700183Simulating using ndnSIM
184-----------------------
185
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700186- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700187
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700188 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
189 described in :doc:`examples section of this tutorial <examples>`. For example, to run
190 ``ndn-simple.cpp`` scenario, you can run the following command:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800191
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700192 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800193
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700194 ./waf --run=ndn-simple
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800195
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700196 To run ``ndn-grid.cpp`` scenario:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800197
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700198 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800199
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700200 ./waf --run=ndn-grid
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800201
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700202 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
203 this will work only when NS-3 is compiled in debug mode):
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800204
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700205 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800206
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700207 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800208
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700209 If you have compiled with python bindings, then you can try to run these simulations with
210 visualizer:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800211
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700212 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800213
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700214 ./waf --run=ndn-simple --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800215
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700216 or:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800217
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700218 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800219
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700220 ./waf --run=ndn-grid --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800221
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700222 .. note::
223 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
224 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800225
226- Real experimentation
227
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700228 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800229
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700230 Alternative and a recommended way is to write simulation scenarios in a separate
231 repository, not related to either NS-3 or ndnSIM. For example, you can use the
232 following template to write your extensions, simulation scenarios, and metric processing
233 scripts: `<http://github.com/cawka/ndnSIM-scenario-template>`_:
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 mkdir ndnSIM
238 cd ndnSIM
239 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
240 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
241 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800242
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700243 # Build and install NS-3 and ndnSIM
244 cd ns-3
245 ./waf configure -d optimized
246 ./waf
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800247
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700248 sudo ./waf install
249 cd ..
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800250
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700251 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
252 cd scenario
253 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
254 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800255
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700256 ./waf configure
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800257
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700258 ./waf --run <scenario>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800259
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700260 For more detailed information, refer to `README file
261 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800262
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700263..
264 Examples of template-based simulations
265 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800266
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700267 1. ndnSIM examples from `<http://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800268
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700269 - `<http://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700270
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700271 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
272 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 -0700273
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700274 - `<http://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700275
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700276 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
277 Information Dissemination Using Named Data" paper by Wang et
278 al. (`<http://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700279
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700280 - `<http://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700281
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700282 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
283 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700284
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700285 - `<http://github.com/cawka/ndnSIM-sample-topologies>`_, or