blob: 079fb03fc4fafbd2955f0f85a2cb1010fb20ba86 [file] [log] [blame]
Steve DiBenedetto62a93942014-08-24 17:13:52 -06001Getting Started with NFD
2========================
Alexander Afanasyev284257b2014-04-11 14:16:51 -07003
Steve DiBenedetto62a93942014-08-24 17:13:52 -06004Installing NFD from Binaries
5----------------------------
6
7We provide NFD binaries for the supported platforms, which are the preferred installation
8method. In addition to simplifying installation, the binary release also includes
9automatic initial configuration and platform-specific tools to automatically start NFD and
10related daemons. In particular, on OS X NFD is controlled using `launchd
11<https://github.com/named-data/NFD/tree/master/contrib/osx-launchd>`__ and on Ubuntu using
12`upstart <https://github.com/named-data/NFD/tree/master/contrib/upstart>`__ mechanisms.
13In both cases, `nfd-start` and `nfd-stop` scripts are convenience wrappers for launchd and
14upstart.
15
16On OS X, NFD can be installed with MacPorts. Refer to :ref:`Install NFD Using the NDN
17MacPorts Repository on OS X` for more details.
18
Davide Pesaventocc7bee72016-04-22 02:21:13 +020019On Ubuntu 14.04 and 16.04, NFD can be installed from NDN PPA repository. Refer to
Steve DiBenedetto62a93942014-08-24 17:13:52 -060020:ref:`Install NFD Using the NDN PPA Repository on Ubuntu Linux`.
21
22Future releases could include support for other platforms. Please send us feedback on the
23platforms you're using, so we can prioritize our goals. We would also appreciate help
24packaging the current NFD release for other platforms.
25
26
27.. _Install NFD Using the NDN MacPorts Repository on OS X:
28
29Install NFD Using the NDN MacPorts Repository on OS X
30-----------------------------------------------------
31
32OS X users have the opportunity to seamlessly install and run NFD as well as other related
33applications via `MacPorts <https://www.macports.org/>`_. If you are not using MacPorts
34yet, go to the `MacPorts website <https://www.macports.org/install.php>`_ and install the
35MacPorts package.
36
37NFD and related ports are not part of the official MacPorts repository. In order to use
38these ports, you will need to add the NDN MacPorts repository to your local configuration.
39In particular, you will need to modify the list of source URLs for MacPorts. For example,
40if your MacPorts are installed in ``/opt/local``, add the following line to
41`/opt/local/etc/macports/sources.conf` before or after the default port repository:
42
43::
44
45 rsync://macports.named-data.net/macports/
46
47After this step, you can use ``sudo port selfupdate`` to fetch updated port definitions.
48
49The following command will install NFD using MacPorts:
50
51::
52
53 sudo port install nfd
54
55.. note::
56
57 You have to have XCode installed on your machine. This can be installed from the
58 AppStore (free) on OS X 10.7 or later. Older editions of OS X can download an
59 appropriate version of XCode from http://developer.apple.com.
60
61
62One advantage of using MacPorts is that you can easily upgrade NFD and other packages to
63the latest version. The following commands will do this job:
64
65::
66
67 sudo port selfupdate
68 sudo port upgrade nfd
69
70.. _Install NFD Using the NDN PPA Repository on Ubuntu Linux:
71
72Install NFD Using the NDN PPA Repository on Ubuntu Linux
73--------------------------------------------------------
74
Davide Pesaventocc7bee72016-04-22 02:21:13 +020075NFD binaries and related tools for Ubuntu 14.04 and 16.04 can be installed using PPA
Steve DiBenedetto62a93942014-08-24 17:13:52 -060076packages from named-data repository. First, you will need to add ``named-data/ppa``
77repository to binary package sources and update list of available packages.
78
79Preliminary steps if you haven't used PPA packages before
80~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81
82To simplify adding new PPA repositories, Ubuntu provides ``add-apt-repository`` tool,
Davide Pesaventocc7bee72016-04-22 02:21:13 +020083which is not installed by default on some systems.
Steve DiBenedetto62a93942014-08-24 17:13:52 -060084
85::
86
87 sudo apt-get install software-properties-common
88
Steve DiBenedetto62a93942014-08-24 17:13:52 -060089Adding NDN PPA
90~~~~~~~~~~~~~~
91
92After installing ``add-apt-repository``, run the following command to add `NDN PPA
93repository`_.
94
95::
96
97 sudo add-apt-repository ppa:named-data/ppa
98 sudo apt-get update
99
100Installing NFD and other NDN packages
101~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102
103After you have added `NDN PPA repository`_, NFD and other NDN packages can be easily
104installed in a standard way, i.e., either using ``apt-get`` as shown below or using any
105other package manager, such as Synaptic Package Manager:
106
107::
108
109 sudo apt-get install nfd
110
111For the list of available packages, refer to `NDN PPA repository`_ homepage.
112
113.. _NDN PPA repository: https://launchpad.net/~named-data/+archive/ppa
114
115Building from Source
116--------------------
117
118Downloading from Git
119~~~~~~~~~~~~~~~~~~~~
120
121The first step is to obtain the source code for ``NFD`` and, its main dependency, the
122``ndn-cxx`` library. If you are not planning to work with the bleeding edge code, make
123sure you checkout the correct release tag (e.g., ``*-0.2.0``) for both repositories:
124
125::
126
127 # Download ndn-cxx
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600128 git clone https://github.com/named-data/ndn-cxx
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600129
130 # Download NFD
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600131 git clone --recursive https://github.com/named-data/NFD
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700132
133Prerequisites
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600134~~~~~~~~~~~~~
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700135
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600136- Install the `ndn-cxx library <http://named-data.net/doc/ndn-cxx/current/INSTALL.html>`_
137 and its requirements
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700138
Junxiao Shie5e1e252014-12-13 22:07:35 -0700139- ``pkg-config``
140
Davide Pesaventocc7bee72016-04-22 02:21:13 +0200141 On OS X with MacPorts:
Junxiao Shie5e1e252014-12-13 22:07:35 -0700142
143 ::
144
145 sudo port install pkgconfig
146
Davide Pesaventocc7bee72016-04-22 02:21:13 +0200147 On Ubuntu:
Junxiao Shie5e1e252014-12-13 22:07:35 -0700148
149 ::
150
151 sudo apt-get install pkg-config
152
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700153- ``libpcap``
154
Davide Pesaventocc7bee72016-04-22 02:21:13 +0200155 Comes with the base system on OS X 10.8, 10.9, 10.10, and 10.11.
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700156
Davide Pesaventocc7bee72016-04-22 02:21:13 +0200157 On Ubuntu:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700158
159 ::
160
161 sudo apt-get install libpcap-dev
162
163To build manpages and API documentation:
164
165- ``doxygen``
166- ``graphviz``
167- ``python-sphinx``
168
Davide Pesaventocc7bee72016-04-22 02:21:13 +0200169 On OS X with MacPorts:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700170
171 ::
172
173 sudo port install doxygen graphviz py27-sphinx sphinx_select
174 sudo port select sphinx py27-sphinx
175
Davide Pesaventocc7bee72016-04-22 02:21:13 +0200176 On Ubuntu:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700177
178 ::
179
180 sudo apt-get install doxygen graphviz python-sphinx
181
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700182
Junxiao Shie5e1e252014-12-13 22:07:35 -0700183Besides officially supported platforms, NFD is known to work on: Fedora 20, CentOS 6/7, Gentoo Linux,
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600184Raspberry Pi, OpenWRT, FreeBSD 10.0, and several other platforms. We are soliciting help
185with documenting common problems / pitfalls in installing/using NFD on different platforms
186on `NFD Wiki
187<http://redmine.named-data.net/projects/nfd/wiki/Wiki#Installation-experiences-for-selected-platforms>`__.
188
189
190Build
191~~~~~
192
193The following basic commands should be used to build NFD on Ubuntu:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700194
195::
196
197 ./waf configure
198 ./waf
199 sudo ./waf install
200
Alexander Afanasyev6db058c2014-11-13 16:46:25 -0800201If you have installed `ndn-cxx` library and/or other dependencies into a non-standard paths, you
202may need to modify ``PKG_CONFIG_PATH`` environment variable before running ``./waf configure``.
203For example,
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700204
205::
206
Alexander Afanasyev6db058c2014-11-13 16:46:25 -0800207 export PKG_CONFIG_PATH=/custom/lib/pkgconfig:$PKG_CONFIG_PATH
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700208 ./waf configure
209 ./waf
210 sudo ./waf install
211
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600212
213Refer to ``./waf --help`` for more options that can be used during ``configure`` stage and
214how to properly configure and run NFD.
215
Alexander Afanasyev508411e2014-12-16 13:27:59 -0800216.. note::
217 If you are working on a source repository that has been compiled before, and you have
218 upgraded one of the dependencies, please execute ``./waf distclean`` to clear object files
219 and start over.
220
Alexander Afanasyev26181532014-05-07 23:38:51 -0700221Debug symbols
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600222~~~~~~~~~~~~~
Alexander Afanasyev26181532014-05-07 23:38:51 -0700223
224The default compiler flags enable debug symbols to be included in binaries. This
225potentially allows more meaningful debugging if NFD or other tools happen to crash.
226
227If it is undesirable, default flags can be easily overridden. The following example shows
228how to completely disable debug symbols and configure NFD to be installed into ``/usr``
229with configuration in ``/etc`` folder.
230
231::
232
233 CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc
234 ./waf
235 sudo ./waf install
236
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800237Customize Compiler
238~~~~~~~~~~~~~~~~~~
239
240To customize compiler, set ``CXX`` environment variable to point to compiler binary and, in
241some case, specify type of the compiler using ``--check-cxx-compiler``. For example, when
242using clang compiler on Linux system, use the following:
243
244::
245
246 CXX=clang++ ./waf configure --check-cxx-compiler=clang++
247
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700248Building documentation
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600249~~~~~~~~~~~~~~~~~~~~~~
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700250
251NFD tutorials and API documentation can be built using the following commands:
252
253::
254
255 # Full set of documentation (tutorials + API) in build/docs
256 ./waf docs
257
258 # Only tutorials in `build/docs`
259 ./waf sphinx
260
261 # Only API docs in `build/docs/doxygen`
262 ./waf doxgyen
263
264
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600265Manpages are automatically created and installed during the normal build process (e.g.,
266during ``./waf`` and ``./waf install``), if ``python-sphinx`` module is detected during
267``./waf configure`` stage. By default, manpages are installed into
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700268``${PREFIX}/share/man`` (where default value for ``PREFIX`` is ``/usr/local``). This
269location can be changed during ``./waf configure`` stage using ``--prefix``,
270``--datarootdir``, or ``--mandir`` options.
271
272For more details, refer to ``./waf --help``.
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600273
274
275Initial configuration
276---------------------
277
278.. note::
279 If you have installed NFD from binary packages, the package manager has already
280 installed initial configuration and you can safely skip this section.
281
282General
283~~~~~~~
284
285After installing NFD from source, you need to create a proper config file. If default
286location for ``./waf configure`` was used, this can be accomplished by simply copying the
287sample configuration file:
288
289::
290
291 sudo cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf
292
293NFD Security
294~~~~~~~~~~~~
295
296NFD provides mechanisms to enable strict authorization for all management commands. In
297particular, one can authorize only specific public keys to create new Faces or change the
298forwarding strategy for specific namespaces. For more information about how to generate
299private/public key pair, generate self-signed certificate, and use this self-signed
300certificate to authorize NFD management commands refer to :ref:`How to configure NFD
301security` FAQ question.
302
303In the sample configuration file, all authorizations are disabled, effectively allowing
304anybody on the local machine to issue NFD management commands. **The sample file is
305intended only for demo purposes and MUST NOT be used in a production environment.**
306
307Running
308-------
309
310**You should not run ndnd or ndnd-tlv, otherwise NFD will not work correctly**
311
312Starting
313~~~~~~~~
314
315In order to use NFD, you need to start two separate daemons: ``nfd`` (the forwarder
316itself) and ``nrd`` (RIB manager that will manage all prefix registrations). The
317recommended way is to use `nfd-start` script:
318
319::
320
321 nfd-start
322
323On OS X it may ask for your keychain password or ask ``nfd/nrd wants to sign using key in
324your keychain.`` Enter your keychain password and click Always Allow.
325
326Later, you can stop NFD with ``nfd-stop`` or by simply killing the ``nfd`` process.
327
328
329Connecting to remote NFDs
330~~~~~~~~~~~~~~~~~~~~~~~~~
331
332To create a UDP or TCP tunnel to remote NFD and create route toward it, use the following
333command in terminal:
334
335::
336
337 nfdc register /ndn udp://<other host>
338
339where ``<other host>`` is the name or IP address of the other host (e.g.,
340``udp://spurs.cs.ucla.edu``). This outputs:
341
342::
343
344 Successful in name registration: ControlParameters(Name: /ndn, FaceId: 260, Origin: 255, Cost: 0, Flags: 1, )
345
346The ``/ndn`` means that NFD will forward all Interests that start with ``/ndn`` through
347the face to the other host. If you only want to forward Interests with a certain prefix,
348use it instead of ``/ndn``. This only forwards Interests to the other host, but there is
349no "back route" for the other host to forward Interests to you. For that, you must go to
350the other host and use ``nfdc`` to add the route.
351
352The "back route" can also be automatically configured with ``nfd-autoreg``. For more
353information refer to :doc:`manpages/nfd-autoreg`.
354
355Playing with NFD
356----------------
357
358After you haved installed, configured, and started NFD, you can try to install and play
359with the following:
360
361Sample applications:
362
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800363- `Simple examples in ndn-cxx library <http://named-data.net/doc/ndn-cxx/current/examples.html>`_
364
365 If you have installed ndn-cxx from source, you already have compiled these:
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600366
367 + examples/producer
368 + examples/consumer
369 + examples/consumer-with-timer
370
371 + tools/ndncatchunks3
372 + tools/ndnputchunks3
373
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800374- `Introductory examples of NDN-CCL
375 <http://redmine.named-data.net/projects/application-development-documentation-guides/wiki/Step-By-Step_-_Common_Client_Libraries>`_
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600376
377Real applications and libraries:
378
379 + `ndn-tlv-ping - Reachability Testing Tool for NDN
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800380 <https://github.com/named-data/ndn-tlv-ping>`_
381 + `ndn-traffic-generator - Traffic Generator For NDN
382 <https://github.com/named-data/ndn-traffic-generator>`_
383 + `repo-ng - Next generation of NDN repository <https://github.com/named-data/repo-ng>`_
384 + `ChronoChat - Multi-user NDN chat application <https://github.com/named-data/ChronoChat>`_
385 + `ChronoSync - Sync library for multiuser realtime applications for NDN
386 <https://github.com/named-data/ChronoSync>`_