blob: 8d4f08b25437d2aa998ad6d3af17bfc7ee793cdf [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
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -04008method. In addition to simplifying installation, the binary release also includes automatic
9initial configuration and platform-specific tools to automatically start NFD and related
10daemons. In particular, on macOS the binary release of NFD comes as part of `NDN Control
11Center <https://named-data.net/codebase/applications/ndn-control-center/>`__ and provides a
12convenient way to configure and launch NFD daemon. :ref:`PPA packages for Ubuntu <Install NFD
13Using the NDN PPA Repository on Ubuntu Linux>` include ``upstart`` and ``systemd``
14configuration to automatically start daemon after boot.
Steve DiBenedetto62a93942014-08-24 17:13:52 -060015
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040016Besides officially supported platforms, NFD is known to work on: Fedora 20+, CentOS 6+, Gentoo
17Linux, Raspberry Pi, OpenWRT, FreeBSD 10+, and several `other platforms
18<https://redmine.named-data.net/projects/nfd/wiki/Wiki#Installation-experiences-for-selected-platforms>`__.
19We would also appreciate feedback and help packaging NDN releases for other platforms.
Steve DiBenedetto62a93942014-08-24 17:13:52 -060020
21.. _Install NFD Using the NDN PPA Repository on Ubuntu Linux:
22
23Install NFD Using the NDN PPA Repository on Ubuntu Linux
24--------------------------------------------------------
25
Davide Pesaventocc7bee72016-04-22 02:21:13 +020026NFD binaries and related tools for Ubuntu 14.04 and 16.04 can be installed using PPA
Steve DiBenedetto62a93942014-08-24 17:13:52 -060027packages from named-data repository. First, you will need to add ``named-data/ppa``
28repository to binary package sources and update list of available packages.
29
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040030Preliminary steps if you have not used PPA packages before
31~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steve DiBenedetto62a93942014-08-24 17:13:52 -060032
33To simplify adding new PPA repositories, Ubuntu provides ``add-apt-repository`` tool,
Davide Pesaventocc7bee72016-04-22 02:21:13 +020034which is not installed by default on some systems.
Steve DiBenedetto62a93942014-08-24 17:13:52 -060035
36::
37
38 sudo apt-get install software-properties-common
39
Steve DiBenedetto62a93942014-08-24 17:13:52 -060040Adding NDN PPA
41~~~~~~~~~~~~~~
42
43After installing ``add-apt-repository``, run the following command to add `NDN PPA
44repository`_.
45
46::
47
48 sudo add-apt-repository ppa:named-data/ppa
49 sudo apt-get update
50
51Installing NFD and other NDN packages
52~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53
54After you have added `NDN PPA repository`_, NFD and other NDN packages can be easily
55installed in a standard way, i.e., either using ``apt-get`` as shown below or using any
56other package manager, such as Synaptic Package Manager:
57
58::
59
60 sudo apt-get install nfd
61
62For the list of available packages, refer to `NDN PPA repository`_ homepage.
63
64.. _NDN PPA repository: https://launchpad.net/~named-data/+archive/ppa
65
66Building from Source
67--------------------
68
69Downloading from Git
70~~~~~~~~~~~~~~~~~~~~
71
72The first step is to obtain the source code for ``NFD`` and, its main dependency, the
73``ndn-cxx`` library. If you are not planning to work with the bleeding edge code, make
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040074sure you checkout the correct release tag (e.g., ``*-0.6.0``) for both repositories:
Steve DiBenedetto62a93942014-08-24 17:13:52 -060075
76::
77
78 # Download ndn-cxx
Steve DiBenedetto62a93942014-08-24 17:13:52 -060079 git clone https://github.com/named-data/ndn-cxx
Steve DiBenedetto62a93942014-08-24 17:13:52 -060080
81 # Download NFD
Steve DiBenedetto62a93942014-08-24 17:13:52 -060082 git clone --recursive https://github.com/named-data/NFD
Alexander Afanasyev284257b2014-04-11 14:16:51 -070083
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040084.. note::
85 While we strive to ensure that the latest version (master branch) of NFD and ndn-cxx
86 always properly compiles and works, sometimes there could be problems. In these cases, use
87 the latest released version.
88
Alexander Afanasyev284257b2014-04-11 14:16:51 -070089Prerequisites
Steve DiBenedetto62a93942014-08-24 17:13:52 -060090~~~~~~~~~~~~~
Alexander Afanasyev284257b2014-04-11 14:16:51 -070091
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040092Install the `ndn-cxx library <https://named-data.net/doc/ndn-cxx/current/INSTALL.html>`__ and its requirements
Alexander Afanasyev284257b2014-04-11 14:16:51 -070093
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040094- On macOS with Homebrew:
Junxiao Shie5e1e252014-12-13 22:07:35 -070095
96 ::
97
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040098 brew install boost openssl pkg-config
Junxiao Shie5e1e252014-12-13 22:07:35 -070099
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400100- On Ubuntu:
Junxiao Shie5e1e252014-12-13 22:07:35 -0700101
102 ::
103
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400104 sudo apt-get install build-essential pkg-config libboost-all-dev \
105 libsqlite3-dev libssl-dev libpcap-dev
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700106
107To build manpages and API documentation:
108
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400109- On macOS with Homebrew:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700110
111 ::
112
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400113 brew install doxygen graphviz
114 sudo easy_install pip
115 sudo pip Sphinx
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700116
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400117- On Ubuntu:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700118
119 ::
120
121 sudo apt-get install doxygen graphviz python-sphinx
122
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600123Build
124~~~~~
125
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400126The following basic commands should be used to build NFD on Ubuntu and macOS with Homebrew:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700127
128::
129
130 ./waf configure
131 ./waf
132 sudo ./waf install
133
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400134If you have installed ``ndn-cxx`` library and/or other dependencies into a non-standard path, you
Alexander Afanasyev6db058c2014-11-13 16:46:25 -0800135may need to modify ``PKG_CONFIG_PATH`` environment variable before running ``./waf configure``.
136For example,
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700137
138::
139
Alexander Afanasyev6db058c2014-11-13 16:46:25 -0800140 export PKG_CONFIG_PATH=/custom/lib/pkgconfig:$PKG_CONFIG_PATH
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700141 ./waf configure
142 ./waf
143 sudo ./waf install
144
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600145Refer to ``./waf --help`` for more options that can be used during ``configure`` stage and
146how to properly configure and run NFD.
147
Alexander Afanasyev508411e2014-12-16 13:27:59 -0800148.. note::
149 If you are working on a source repository that has been compiled before, and you have
150 upgraded one of the dependencies, please execute ``./waf distclean`` to clear object files
151 and start over.
152
Alexander Afanasyev26181532014-05-07 23:38:51 -0700153Debug symbols
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600154~~~~~~~~~~~~~
Alexander Afanasyev26181532014-05-07 23:38:51 -0700155
156The default compiler flags enable debug symbols to be included in binaries. This
157potentially allows more meaningful debugging if NFD or other tools happen to crash.
158
159If it is undesirable, default flags can be easily overridden. The following example shows
160how to completely disable debug symbols and configure NFD to be installed into ``/usr``
161with configuration in ``/etc`` folder.
162
163::
164
165 CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc
166 ./waf
167 sudo ./waf install
168
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400169.. note::
170 For Ubuntu PPA packages debug symbols are available in ``*-dbg`` packages.
171
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800172Customize Compiler
173~~~~~~~~~~~~~~~~~~
174
Eric Newberry81a9a862016-12-27 22:59:27 -0700175To choose a custom C++ compiler for building NFD, set the ``CXX`` environment variable
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400176to point to the compiler binary. For example, to select the clang compiler on a Linux
Eric Newberry81a9a862016-12-27 22:59:27 -0700177system, use the following:
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800178
179::
180
Eric Newberry81a9a862016-12-27 22:59:27 -0700181 CXX=clang++ ./waf configure
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800182
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700183Building documentation
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600184~~~~~~~~~~~~~~~~~~~~~~
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700185
186NFD tutorials and API documentation can be built using the following commands:
187
188::
189
190 # Full set of documentation (tutorials + API) in build/docs
191 ./waf docs
192
193 # Only tutorials in `build/docs`
194 ./waf sphinx
195
196 # Only API docs in `build/docs/doxygen`
197 ./waf doxgyen
198
199
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600200Manpages are automatically created and installed during the normal build process (e.g.,
201during ``./waf`` and ``./waf install``), if ``python-sphinx`` module is detected during
202``./waf configure`` stage. By default, manpages are installed into
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700203``${PREFIX}/share/man`` (where default value for ``PREFIX`` is ``/usr/local``). This
204location can be changed during ``./waf configure`` stage using ``--prefix``,
205``--datarootdir``, or ``--mandir`` options.
206
207For more details, refer to ``./waf --help``.
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600208
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600209Initial configuration
210---------------------
211
212.. note::
213 If you have installed NFD from binary packages, the package manager has already
214 installed initial configuration and you can safely skip this section.
215
216General
217~~~~~~~
218
219After installing NFD from source, you need to create a proper config file. If default
220location for ``./waf configure`` was used, this can be accomplished by simply copying the
221sample configuration file:
222
223::
224
225 sudo cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf
226
227NFD Security
228~~~~~~~~~~~~
229
230NFD provides mechanisms to enable strict authorization for all management commands. In
231particular, one can authorize only specific public keys to create new Faces or change the
232forwarding strategy for specific namespaces. For more information about how to generate
233private/public key pair, generate self-signed certificate, and use this self-signed
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400234certificate to authorize NFD management commands, refer to :ref:`How to configure NFD
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600235security` FAQ question.
236
237In the sample configuration file, all authorizations are disabled, effectively allowing
238anybody on the local machine to issue NFD management commands. **The sample file is
239intended only for demo purposes and MUST NOT be used in a production environment.**
240
241Running
242-------
243
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600244Starting
245~~~~~~~~
246
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400247If you have installed NFD from source code, it is recommended to start NFD with the
248``nfd-start`` script:
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600249
250::
251
252 nfd-start
253
Junxiao Shi849e12a2017-08-02 00:14:57 +0000254On macOS it may ask for your keychain password or ask ``nfd wants to sign using key in
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600255your keychain.`` Enter your keychain password and click Always Allow.
256
257Later, you can stop NFD with ``nfd-stop`` or by simply killing the ``nfd`` process.
258
Junxiao Shi849e12a2017-08-02 00:14:57 +0000259If you have installed NFD using a package manager, you can start and stop NFD service using the
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400260operating system's service manager (such as Upstart, systemd, or launchd) or using
261"Automatically start NFD" option in NDN Control Center app.
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600262
263Connecting to remote NFDs
264~~~~~~~~~~~~~~~~~~~~~~~~~
265
Junxiao Shi849e12a2017-08-02 00:14:57 +0000266To create a UDP tunnel to a remote NFD, execute the following command in terminal:
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600267
268::
269
Junxiao Shi849e12a2017-08-02 00:14:57 +0000270 nfdc face create udp://<other host>
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600271
272where ``<other host>`` is the name or IP address of the other host (e.g.,
273``udp://spurs.cs.ucla.edu``). This outputs:
274
275::
276
Junxiao Shi849e12a2017-08-02 00:14:57 +0000277 face-created id=308 local=udp4://10.0.2.15:6363 remote=udp4://131.179.196.46:6363 persistency=persistent
278
279To add a route ``/ndn`` toward the remote NFD, execute the following command in terminal:
280
281::
282
283 nfdc route add /ndn udp://<other host>
284
285This outputs:
286
287::
288
289 route-add-accepted prefix=/ndn nexthop=308 origin=static cost=0 flags=child-inherit expires=never
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600290
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400291The ``/ndn`` means that NFD will forward all Interests that start with ``/ndn`` through the
292face to the other host. If you only want to forward Interests with a certain prefix, use it
293instead of ``/ndn``. This only forwards Interests to the other host, but there is no "back
294route" for the other host to forward Interests to you. For that, you can rely on automatic
295prefix propagation feature of NFD or go to the other host and use ``nfdc`` to add the route.
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600296
297Playing with NFD
298----------------
299
300After you haved installed, configured, and started NFD, you can try to install and play
301with the following:
302
303Sample applications:
304
Eric Newberry81a9a862016-12-27 22:59:27 -0700305- `Simple examples in ndn-cxx library <https://named-data.net/doc/ndn-cxx/current/examples.html>`_
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800306
307 If you have installed ndn-cxx from source, you already have compiled these:
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600308
309 + examples/producer
310 + examples/consumer
311 + examples/consumer-with-timer
312
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800313- `Introductory examples of NDN-CCL
Eric Newberry81a9a862016-12-27 22:59:27 -0700314 <https://redmine.named-data.net/projects/application-development-documentation-guides/wiki/Step-By-Step_-_Common_Client_Libraries>`_
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600315
316Real applications and libraries:
317
Junxiao Shiaf9aa362016-07-13 13:18:07 +0000318 + `ndn-tools - NDN Essential Tools <https://github.com/named-data/ndn-tools>`_
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800319 + `ndn-traffic-generator - Traffic Generator For NDN
320 <https://github.com/named-data/ndn-traffic-generator>`_
321 + `repo-ng - Next generation of NDN repository <https://github.com/named-data/repo-ng>`_
322 + `ChronoChat - Multi-user NDN chat application <https://github.com/named-data/ChronoChat>`_
323 + `ChronoSync - Sync library for multiuser realtime applications for NDN
324 <https://github.com/named-data/ChronoSync>`_