blob: 3076cebae2bd9c29e55a9d7dcc771a47a2d2c419 [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 Afanasyev90d50392022-05-05 13:07:24 -040012- Ubuntu 20.04 (amd64)
13- Ubuntu 21.10 (amd64)
14- macOS 12 (Intel only)
15- macOS 11 (Intel only)
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 Afanasyev90d50392022-05-05 13:07:24 -040024- GCC >= 7.4 or clang >= 4.0 (on Linux and FreeBSD)
25- Xcode >= 9.0 (on macOS)
26- Python >= 3.6
27- pkg-config
28- Boost >= 1.65.1
29- OpenSSL >= 1.0.2
30- SQLite 3.x
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 HomeBrew:
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080047
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070048 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080049
Alexander Afanasyev24810922019-02-10 22:06:43 -050050 brew install boost pkg-config openssl libxml2
51 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 -080052
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070053- Linux
Alexander Afanasyev326410e2013-03-09 20:39:11 -080054
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040055 * Ubuntu Linux 18.04
Alexander Afanasyev326410e2013-03-09 20:39:11 -080056
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070057 .. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -080058
Alexander Afanasyev24810922019-02-10 22:06:43 -050059 sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python-setuptools castxml
Alexander Afanasyevdf26b5a2015-01-15 23:30:56 -080060
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040061 * Ubuntu Linux 20.04
62
63 .. code-block:: bash
64
65 sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml
66
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
Alexander Afanasyev24810922019-02-10 22:06:43 -050071 sudo yum install gcc-g++ git sqlite-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 HomeBrew
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070088
Alexander Afanasyev24810922019-02-10 22:06:43 -050089 .. code-block:: bash
90
91 brew install cairo goocanvas gtk+3 graphviz gobject-introspection castxml
92
93 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libffi/lib/pkgconfig" # this needed only for running the next line
94 pip install pygraphviz pycairo PyGObject pygccxml
Alexander Afanasyev5dee3612015-08-25 16:09:04 -070095
96- Linux
97
Alexander Afanasyev49ecab22020-05-31 00:03:17 -040098 * Ubuntu Linux 18.04
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -080099
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700100 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800101
Alexander Afanasyev40b88332019-02-13 16:19:06 -0500102 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
103 sudo pip install pygraphviz pycairo PyGObject pygccxml
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800104
Alexander Afanasyev49ecab22020-05-31 00:03:17 -0400105 * Ubuntu Linux 20.04
106
107 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
108 sudo pip3 install kiwi
109
Alexander Afanasyev24810922019-02-10 22:06:43 -0500110.. _visualizer: https://www.nsnam.org/wiki/PyViz
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800111
112Downloading ndnSIM source
113-------------------------
114
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800115ndnSIM package consists of three pieces:
116
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800117- a custom branch of NS-3 that contains a few useful patches
118- a customized python binding generation library (necessary if you want to use NS-3's python
119 bindings and/or visualizer module)
120- the source code of ndnSIM module
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700121- modified source code of ndn-cxx library and NDN Forwarding Daemon (NFD), attached to
122 ndnSIM git repository as git submodules
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800123
124The following commands download all pieces from GitHub repositories:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800125
126.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800127
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800128 mkdir ndnSIM
129 cd ndnSIM
Alexander Afanasyevd6453cd2015-08-20 21:45:36 -0700130 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
131 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
Spyridon Mastorakisa1d135b2015-08-20 20:24:59 -0700132 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800133
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700134The last command downloads ndnSIM source code and source code of all submodules (i.e.,
135ndn-cxx and NFD). If you previously cloned without ``--recursive`` flag, the correct
136versions of submodules can be retrieved using:
137
138.. code-block:: bash
139
140 git submodule update --init
141
142The same command should be run to update submodules when there are new changes available.
143
144.. note::
145 A few modification to the base NS-3 and pybindgen are necessary to run successfully
146 compile and run ndnSIM. Some of the changes are specific to ndnSIM and some are
147 bugfixes that we are submitting to NS-3 upstream. We also periodically update
148 repository with the new NS-3 releases, usually in form of rebasing (and if necessary
149 updating or eliminating) our custom patches on top of the released commits.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800150
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700151
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800152Compiling and running ndnSIM
153----------------------------
154
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700155ndnSIM uses a standard NS-3 compilation procedure. Normally the following commands should be
156sufficient to configure and build ndnSIM with python bindings enabled:
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800157
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700158.. code-block:: bash
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800159
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700160 cd <ns-3-folder>
161 ./waf configure --enable-examples
162 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800163
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700164.. note::
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800165 On macOS configuration stage may get :ref:`stuck at detecting gtk module <Problems with
166 the gtk python module on macOS>`. Make sure you have `XQuartz
Xinyu Mafc8956c2019-04-08 23:17:52 -0700167 <https://xquartz.macosforge.org>`_ installed or disable python as described in the
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700168 following instructions.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800169
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700170Python bindings is an optional and not very stable feature of NS-3 simulator. It is
171possible to disable python bindings compilation either to speed up compilation or to avoid
172certain compilation errors (e.g., "Could not find a task generator for the name
173'ns3-visualizer'"):
Spyridon Mastorakisc33e2882015-01-20 21:45:44 -0800174
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700175.. code-block:: bash
Alexander Afanasyev326410e2013-03-09 20:39:11 -0800176
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700177 cd <ns-3-folder>
178 ./waf configure --disable-python --enable-examples
179 ./waf
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800180
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700181For more configuration options, please refer to ``./waf --help``.
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -0800182
Spyridon Mastorakisf34b3192015-02-16 17:42:01 -0800183
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700184Simulating using ndnSIM
185-----------------------
186
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700187- Example simulation scenarios
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700188
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700189 When NS-3 is configured with ``--with-examples`` flag, you can directly run all examples
190 described in :doc:`examples section of this tutorial <examples>`. For example, to run
191 ``ndn-simple.cpp`` scenario, you can run the following command:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800192
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700193 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800194
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700195 ./waf --run=ndn-simple
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800196
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700197 To run ``ndn-grid.cpp`` scenario:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800198
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700199 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800200
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700201 ./waf --run=ndn-grid
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800202
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700203 To run the sample simulation scenarios with the logging module of NS-3 enabled (note that
204 this will work only when NS-3 is compiled in debug mode):
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800205
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700206 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800207
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700208 NS_LOG=ndn.Producer:ndn.Consumer ./waf --run=<scenario name>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800209
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700210 If you have compiled with python bindings, then you can try to run these simulations with
211 visualizer:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800212
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700213 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800214
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700215 ./waf --run=ndn-simple --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800216
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700217 or:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800218
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700219 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800220
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700221 ./waf --run=ndn-grid --vis
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800222
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700223 .. note::
224 Do not forget to configure and compile NS-3 in optimized mode (``./waf configure -d
225 optimized``) in order to run actual simulations.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800226
227- Real experimentation
228
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700229 Simulation scenarios can be written directly inside NS-3 in ``scratch/`` or ``src/ndnSIM/examples`` folder.
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800230
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700231 Alternative and a recommended way is to write simulation scenarios in a separate
232 repository, not related to either NS-3 or ndnSIM. For example, you can use the
233 following template to write your extensions, simulation scenarios, and metric processing
Xinyu Mafc8956c2019-04-08 23:17:52 -0700234 scripts: `<https://github.com/cawka/ndnSIM-scenario-template>`_:
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800235
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700236 .. code-block:: bash
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800237
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700238 mkdir ndnSIM
239 cd ndnSIM
240 git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3
241 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen
242 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800243
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700244 # Build and install NS-3 and ndnSIM
245 cd ns-3
246 ./waf configure -d optimized
247 ./waf
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800248
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700249 sudo ./waf install
250 cd ..
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800251
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700252 git clone https://github.com/named-data-ndnSIM/scenario-template.git scenario
253 cd scenario
254 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
255 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800256
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700257 ./waf configure
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800258
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700259 ./waf --run <scenario>
Spyridon Mastorakisacd5e1a2016-12-07 14:34:25 -0800260
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700261 For more detailed information, refer to `README file
262 <https://github.com/cawka/ndnSIM-scenario-template/blob/master/README.md>`_.
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800263
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700264..
265 Examples of template-based simulations
266 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800267
Xinyu Mafc8956c2019-04-08 23:17:52 -0700268 1. ndnSIM examples from `<https://ndnsim.net>`_ website and more:
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -0800269
Xinyu Mafc8956c2019-04-08 23:17:52 -0700270 - `<https://github.com/cawka/ndnSIM-examples>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700271
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700272 2. Script scenarios and graph processing scripts for simulations used in "A Case for Stateful
Xinyu Mafc8956c2019-04-08 23:17:52 -0700273 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 -0700274
Xinyu Mafc8956c2019-04-08 23:17:52 -0700275 - `<https://github.com/cawka/ndnSIM-comcom-stateful-fw>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700276
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700277 3. Script scenarios and graph processing scripts for simulations used in "Rapid Traffic
278 Information Dissemination Using Named Data" paper by Wang et
Xinyu Mafc8956c2019-04-08 23:17:52 -0700279 al. (`<https://dx.doi.org/10.1145/2248361.2248365>`_):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700280
Xinyu Mafc8956c2019-04-08 23:17:52 -0700281 - `<https://github.com/cawka/ndnSIM-nom-rapid-car2car>`_, or
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700282
Alexander Afanasyev5dee3612015-08-25 16:09:04 -0700283 - Rocketfuel-based topology generator for ndnSIM preferred format (randomly assigned link
284 delays and bandwidth, based on estimated types of connections between nodes):
Alexander Afanasyev701e5082013-03-13 09:47:50 -0700285
Xinyu Mafc8956c2019-04-08 23:17:52 -0700286 - `<https://github.com/cawka/ndnSIM-sample-topologies>`_, or