blob: b1a42ff9abdbe2380d3cc71ab12ced975b45b6c1 [file] [log] [blame]
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -08001Getting Started
2===============
3
4Portability
5------------
6
Alexander Afanasyev40b88332019-02-13 16:19:06 -05007.. image:: https://travis-ci.org/named-data-ndnSIM/ndnSIM.svg?branch=master
Alexander Afanasyev5dee3612015-08-25 16:09:04 -07008 :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 Afanasyev49ecab22020-05-31 00:03:17 -040012- Ubuntu Linux 20.04
Alexander Afanasyev40b88332019-02-13 16:19:06 -050013- Ubuntu Linux 18.04
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040014- macOS 10.15
Alexander Afanasyev40b88332019-02-13 16:19:06 -050015- macOS 10.14
Alexander Afanasyev8e60bcd2015-01-15 20:55:40 +000016
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080017.. _requirements:
18
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080019Prerequisites
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080020-------------
21
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070022**1. Core dependencies**
23
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040024- ``python`` >= 3.5
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070025- ``libsqlite3``
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070026- ``pkg-config``
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080027- ``openssl``
28- Boost libraries >= 1.54
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080029
Alexander Afanasyev26b558b2012-12-13 11:39:46 -080030.. role:: red
31
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080032.. note::
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -080033 If you do not have root permissions to install boost, you can install it in your home
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080034 folder. However, you need to be make sure that `libboost_iostreams` library is successfully
35 compiled and is installed. Please refer to :ref:`the following example <Installing boost
36 libraries>` for the hints how to successfully compile and install boost libraries on Ubuntu
37 Linux.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080038
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070039Following are the detailed steps for each platform to install the compiler, all necessary
40development tools and libraries, and ndn-cxx prerequisites.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080041
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080042- macOS
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080043
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080044 * macOS with HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080045
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070046 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080047
Alexander Afanasyev24810922019-02-10 22:06:43 -050048 brew install boost pkg-config openssl libxml2
49 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 -080050
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070051- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080052
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040053 * Ubuntu Linux 18.04
Alexander Afanasyev326410e2013-03-09 20:39:11 -080054
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070055 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080056
Alexander Afanasyev24810922019-02-10 22:06:43 -050057 sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python-setuptools castxml
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080058
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040059 * Ubuntu Linux 20.04
60
61 .. code-block:: bash
62
63 sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml
64
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070065 * Fedora Linux
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080066
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070067 .. code-block:: bash
68
Alexander Afanasyev24810922019-02-10 22:06:43 -050069 sudo yum install gcc-g++ git sqlite-devel boost-devel openssl-devel
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070070
71 .. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080072 :red:`ndnSIM requires boost version at least 1.54.` Many linux distribution
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070073 (Fedora 16, 17 at the time of this writing) ship an old version of boost, making it
74 impossible to compile ndnSIM out-of-the-box. Please install the latest version, following
75 :ref:`these simple instructions <Installing boost libraries>`.
76
77**2. Dependencies for NS-3 Python bindings**
78
79If you are planning to use NS-3 python bindings, a number of additional dependencies
80should be installed. For example, in order to run `visualizer`_ module, the following
81should be installed:
82
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080083- macOS
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070084
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080085 * macOS with HomeBrew
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070086
Alexander Afanasyev24810922019-02-10 22:06:43 -050087 .. code-block:: bash
88
89 brew install cairo goocanvas gtk+3 graphviz gobject-introspection castxml
90
91 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig" # this needed only for running the next line
92 pip install pygraphviz pycairo PyGObject pygccxml
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070093
94- Linux
95
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040096 * Ubuntu Linux 18.04
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080097
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070098 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080099
Alexander Afanasyev40b88332019-02-13 16:19:06 -0500100 sudo apt install python-dev python-pygraphviz python-kiwi python-gnome2 ipython libcairo2-dev python3-gi libgirepository1.0-dev python-gi python-gi-cairo gir1.2-gtk-3.0 gir1.2-goocanvas-2.0 python-pip
101 sudo pip install pygraphviz pycairo PyGObject pygccxml
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800102
Alexander Afanasyev49ecab22020-05-31 00:03:17 -0400103 * Ubuntu Linux 20.04
104
105 sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml
106 sudo pip3 install kiwi
107
Alexander Afanasyev24810922019-02-10 22:06:43 -0500108.. _visualizer: https://www.nsnam.org/wiki/PyViz
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800109
110Downloading ndnSIM source
111-------------------------
112
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800113ndnSIM package consists of three pieces:
114
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800115- a custom branch of NS-3 that contains a few useful patches
116- a customized python binding generation library (necessary if you want to use NS-3's python
117 bindings and/or visualizer module)
118- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700119- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
120 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800121
122The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800123
124.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800125
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800126 mkdir ndnSIM
127 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700128 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
129 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700130 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800131
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700132The last command downloads ndnSIM source code and source code of all submodules (i.e.,
133ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
134versions of submodules can be retrieved using:
135
136.. code-block:: bash
137
138 git submodule update --init
139
140The same command should be run to update submodules when there are new changes available.
141
142.. note::
143 A few modification to the base NS-3 and pybindgen are necessary to run successfully
144 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
145 bugfixes that we are submitting to NS-3 upstream. We also periodically update
146 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
147 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800148
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700149
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800150Compiling and running ndnSIM
151----------------------------
152
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700153ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
154sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800155
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700156.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800157
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700158 cd <ns-3-folder>
159 ./waf configure --enable-examples
160 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800161
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700162.. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800163 On macOS configuration stage may get :ref:`stuck at detecting gtk module <Problems with
164 the gtk python module on macOS>`. Make sure you have `XQuartz
Xinyu Mafc8956c2019-04-08 23:17:52 -0700165 <https://xquartz.macosforge.org>`_ installed or disable python as described in the
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700166 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800167
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700168Python bindings is an optional and not very stable feature of NS-3 simulator. It is
169possible to disable python bindings compilation either to speed up compilation or to avoid
170certain compilation errors (e.g., "Could not find a task generator for the name
171'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -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 --disable-python --enable-examples
177 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800178
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700179For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800180
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800181
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700182Simulating using ndnSIM
183-----------------------
184
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700185- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700186
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700187 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
188 described in :doc:`examples section of this tutorial <examples>`. For example, to run
189 ``ndn-simple.cpp`` scenario, you can run the following command:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800190
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700191 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800192
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700193 ./waf --run=ndn-simple
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800194
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700195 To run ``ndn-grid.cpp`` scenario:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800196
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700197 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800198
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700199 ./waf --run=ndn-grid
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800200
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700201 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
202 this will work only when NS-3 is compiled in debug mode):
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800203
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700204 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800205
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700206 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800207
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700208 If you have compiled with python bindings, then you can try to run these simulations with
209 visualizer:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800210
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700211 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800212
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700213 ./waf --run=ndn-simple --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800214
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700215 or:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800216
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700217 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800218
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700219 ./waf --run=ndn-grid --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800220
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700221 .. note::
222 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
223 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800224
225- Real experimentation
226
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700227 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800228
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700229 Alternative and a recommended way is to write simulation scenarios in a separate
230 repository, not related to either NS-3 or ndnSIM. For example, you can use the
231 following template to write your extensions, simulation scenarios, and metric processing
Xinyu Mafc8956c2019-04-08 23:17:52 -0700232 scripts: `<https://github.com/cawka/ndnSIM-scenario-template>`_:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800233
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700234 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800235
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700236 mkdir ndnSIM
237 cd ndnSIM
238 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
239 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
240 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800241
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700242 # Build and install NS-3 and ndnSIM
243 cd ns-3
244 ./waf configure -d optimized
245 ./waf
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800246
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700247 sudo ./waf install
248 cd ..
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800249
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700250 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
251 cd scenario
252 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
253 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800254
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700255 ./waf configure
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800256
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700257 ./waf --run <scenario>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800258
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700259 For more detailed information, refer to `README file
260 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800261
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700262..
263 Examples of template-based simulations
264 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800265
Xinyu Mafc8956c2019-04-08 23:17:52 -0700266 1. ndnSIM examples from `<https://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800267
Xinyu Mafc8956c2019-04-08 23:17:52 -0700268 - `<https://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700269
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700270 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
Xinyu Mafc8956c2019-04-08 23:17:52 -0700271 Forwarding Plane" paper by Yi et al. (`<https://dx.doi.org/10.1016/j.comcom.2013.01.005>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700272
Xinyu Mafc8956c2019-04-08 23:17:52 -0700273 - `<https://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700274
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700275 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
276 Information Dissemination Using Named Data" paper by Wang et
Xinyu Mafc8956c2019-04-08 23:17:52 -0700277 al. (`<https://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700278
Xinyu Mafc8956c2019-04-08 23:17:52 -0700279 - `<https://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700280
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700281 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
282 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700283
Xinyu Mafc8956c2019-04-08 23:17:52 -0700284 - `<https://github.com/cawka/ndnSIM-sample-topologies>`_, or