blob: 2f1cc976d42c2447aebed506d5d40d6fba605e47 [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 -06004.. _Install NFD Using the NDN PPA Repository on Ubuntu Linux:
5
6Install NFD Using the NDN PPA Repository on Ubuntu Linux
7--------------------------------------------------------
8
wenkaizheng55d83d42019-08-22 18:36:01 -07009NFD binaries and related tools for the latest versions of Ubuntu Linux can be installed using PPA
Steve DiBenedetto62a93942014-08-24 17:13:52 -060010packages from named-data repository. First, you will need to add ``named-data/ppa``
11repository to binary package sources and update list of available packages.
12
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040013Preliminary steps if you have not used PPA packages before
14~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steve DiBenedetto62a93942014-08-24 17:13:52 -060015
16To simplify adding new PPA repositories, Ubuntu provides ``add-apt-repository`` tool,
Davide Pesaventocc7bee72016-04-22 02:21:13 +020017which is not installed by default on some systems.
Steve DiBenedetto62a93942014-08-24 17:13:52 -060018
19::
20
21 sudo apt-get install software-properties-common
22
Steve DiBenedetto62a93942014-08-24 17:13:52 -060023Adding NDN PPA
24~~~~~~~~~~~~~~
25
26After installing ``add-apt-repository``, run the following command to add `NDN PPA
27repository`_.
28
29::
30
31 sudo add-apt-repository ppa:named-data/ppa
32 sudo apt-get update
33
34Installing NFD and other NDN packages
35~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36
37After you have added `NDN PPA repository`_, NFD and other NDN packages can be easily
38installed in a standard way, i.e., either using ``apt-get`` as shown below or using any
39other package manager, such as Synaptic Package Manager:
40
41::
42
43 sudo apt-get install nfd
44
45For the list of available packages, refer to `NDN PPA repository`_ homepage.
46
47.. _NDN PPA repository: https://launchpad.net/~named-data/+archive/ppa
48
49Building from Source
50--------------------
51
52Downloading from Git
53~~~~~~~~~~~~~~~~~~~~
54
55The first step is to obtain the source code for ``NFD`` and, its main dependency, the
56``ndn-cxx`` library. If you are not planning to work with the bleeding edge code, make
wenkaizheng55d83d42019-08-22 18:36:01 -070057sure you checkout the correct release tag (e.g., ``*-0.6.6``) for both repositories:
Steve DiBenedetto62a93942014-08-24 17:13:52 -060058
59::
60
61 # Download ndn-cxx
Steve DiBenedetto62a93942014-08-24 17:13:52 -060062 git clone https://github.com/named-data/ndn-cxx
Steve DiBenedetto62a93942014-08-24 17:13:52 -060063
64 # Download NFD
Steve DiBenedetto62a93942014-08-24 17:13:52 -060065 git clone --recursive https://github.com/named-data/NFD
Alexander Afanasyev284257b2014-04-11 14:16:51 -070066
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040067.. note::
68 While we strive to ensure that the latest version (master branch) of NFD and ndn-cxx
69 always properly compiles and works, sometimes there could be problems. In these cases, use
70 the latest released version.
71
Alexander Afanasyev284257b2014-04-11 14:16:51 -070072Prerequisites
Steve DiBenedetto62a93942014-08-24 17:13:52 -060073~~~~~~~~~~~~~
Alexander Afanasyev284257b2014-04-11 14:16:51 -070074
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040075Install the `ndn-cxx library <https://named-data.net/doc/ndn-cxx/current/INSTALL.html>`__ and its requirements
Alexander Afanasyev284257b2014-04-11 14:16:51 -070076
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040077- On macOS with Homebrew:
Junxiao Shie5e1e252014-12-13 22:07:35 -070078
79 ::
80
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040081 brew install boost openssl pkg-config
Junxiao Shie5e1e252014-12-13 22:07:35 -070082
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040083- On Ubuntu:
Junxiao Shie5e1e252014-12-13 22:07:35 -070084
85 ::
86
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040087 sudo apt-get install build-essential pkg-config libboost-all-dev \
88 libsqlite3-dev libssl-dev libpcap-dev
Alexander Afanasyev284257b2014-04-11 14:16:51 -070089
90To build manpages and API documentation:
91
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040092- On macOS with Homebrew:
Alexander Afanasyev284257b2014-04-11 14:16:51 -070093
94 ::
95
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -040096 brew install doxygen graphviz
97 sudo easy_install pip
98 sudo pip Sphinx
Alexander Afanasyev284257b2014-04-11 14:16:51 -070099
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400100- On Ubuntu:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700101
102 ::
103
104 sudo apt-get install doxygen graphviz python-sphinx
105
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600106Build
107~~~~~
108
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400109The following basic commands should be used to build NFD on Ubuntu and macOS with Homebrew:
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700110
111::
112
113 ./waf configure
114 ./waf
115 sudo ./waf install
116
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400117If you have installed ``ndn-cxx`` library and/or other dependencies into a non-standard path, you
Alexander Afanasyev6db058c2014-11-13 16:46:25 -0800118may need to modify ``PKG_CONFIG_PATH`` environment variable before running ``./waf configure``.
119For example,
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700120
121::
122
Alexander Afanasyev6db058c2014-11-13 16:46:25 -0800123 export PKG_CONFIG_PATH=/custom/lib/pkgconfig:$PKG_CONFIG_PATH
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700124 ./waf configure
125 ./waf
126 sudo ./waf install
127
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600128Refer to ``./waf --help`` for more options that can be used during ``configure`` stage and
129how to properly configure and run NFD.
130
Alexander Afanasyev508411e2014-12-16 13:27:59 -0800131.. note::
132 If you are working on a source repository that has been compiled before, and you have
133 upgraded one of the dependencies, please execute ``./waf distclean`` to clear object files
134 and start over.
135
Alexander Afanasyev26181532014-05-07 23:38:51 -0700136Debug symbols
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600137~~~~~~~~~~~~~
Alexander Afanasyev26181532014-05-07 23:38:51 -0700138
139The default compiler flags enable debug symbols to be included in binaries. This
140potentially allows more meaningful debugging if NFD or other tools happen to crash.
141
142If it is undesirable, default flags can be easily overridden. The following example shows
143how to completely disable debug symbols and configure NFD to be installed into ``/usr``
144with configuration in ``/etc`` folder.
145
146::
147
148 CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc
149 ./waf
150 sudo ./waf install
151
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400152.. note::
153 For Ubuntu PPA packages debug symbols are available in ``*-dbg`` packages.
154
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800155Customize Compiler
156~~~~~~~~~~~~~~~~~~
157
Eric Newberry81a9a862016-12-27 22:59:27 -0700158To choose a custom C++ compiler for building NFD, set the ``CXX`` environment variable
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400159to point to the compiler binary. For example, to select the clang compiler on a Linux
Eric Newberry81a9a862016-12-27 22:59:27 -0700160system, use the following:
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800161
162::
163
Eric Newberry81a9a862016-12-27 22:59:27 -0700164 CXX=clang++ ./waf configure
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800165
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700166Building documentation
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600167~~~~~~~~~~~~~~~~~~~~~~
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700168
169NFD tutorials and API documentation can be built using the following commands:
170
171::
172
173 # Full set of documentation (tutorials + API) in build/docs
174 ./waf docs
175
176 # Only tutorials in `build/docs`
177 ./waf sphinx
178
179 # Only API docs in `build/docs/doxygen`
180 ./waf doxgyen
181
182
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600183Manpages are automatically created and installed during the normal build process (e.g.,
184during ``./waf`` and ``./waf install``), if ``python-sphinx`` module is detected during
185``./waf configure`` stage. By default, manpages are installed into
Alexander Afanasyev284257b2014-04-11 14:16:51 -0700186``${PREFIX}/share/man`` (where default value for ``PREFIX`` is ``/usr/local``). This
187location can be changed during ``./waf configure`` stage using ``--prefix``,
188``--datarootdir``, or ``--mandir`` options.
189
190For more details, refer to ``./waf --help``.
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600191
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600192Initial configuration
193---------------------
194
195.. note::
196 If you have installed NFD from binary packages, the package manager has already
197 installed initial configuration and you can safely skip this section.
198
199General
200~~~~~~~
201
202After installing NFD from source, you need to create a proper config file. If default
203location for ``./waf configure`` was used, this can be accomplished by simply copying the
204sample configuration file:
205
206::
207
208 sudo cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf
209
210NFD Security
211~~~~~~~~~~~~
212
213NFD provides mechanisms to enable strict authorization for all management commands. In
214particular, one can authorize only specific public keys to create new Faces or change the
215forwarding strategy for specific namespaces. For more information about how to generate
216private/public key pair, generate self-signed certificate, and use this self-signed
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400217certificate to authorize NFD management commands, refer to :ref:`How to configure NFD
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600218security` FAQ question.
219
220In the sample configuration file, all authorizations are disabled, effectively allowing
221anybody on the local machine to issue NFD management commands. **The sample file is
222intended only for demo purposes and MUST NOT be used in a production environment.**
223
224Running
225-------
226
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600227Starting
228~~~~~~~~
229
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400230If you have installed NFD from source code, it is recommended to start NFD with the
231``nfd-start`` script:
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600232
233::
234
235 nfd-start
236
Junxiao Shi849e12a2017-08-02 00:14:57 +0000237On macOS it may ask for your keychain password or ask ``nfd wants to sign using key in
Davide Pesavento2849fd42019-01-03 18:30:05 -0500238your keychain``. Enter your keychain password and click "Always Allow".
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600239
240Later, you can stop NFD with ``nfd-stop`` or by simply killing the ``nfd`` process.
241
Davide Pesavento2849fd42019-01-03 18:30:05 -0500242If you have installed NFD using a package manager, you can start and stop NFD using the
243operating system's service manager (such as systemd or launchd) or using
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400244"Automatically start NFD" option in NDN Control Center app.
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600245
246Connecting to remote NFDs
247~~~~~~~~~~~~~~~~~~~~~~~~~
248
Junxiao Shi849e12a2017-08-02 00:14:57 +0000249To create a UDP tunnel to a remote NFD, execute the following command in terminal:
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600250
251::
252
Junxiao Shi849e12a2017-08-02 00:14:57 +0000253 nfdc face create udp://<other host>
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600254
255where ``<other host>`` is the name or IP address of the other host (e.g.,
256``udp://spurs.cs.ucla.edu``). This outputs:
257
258::
259
Junxiao Shi849e12a2017-08-02 00:14:57 +0000260 face-created id=308 local=udp4://10.0.2.15:6363 remote=udp4://131.179.196.46:6363 persistency=persistent
261
262To add a route ``/ndn`` toward the remote NFD, execute the following command in terminal:
263
264::
265
266 nfdc route add /ndn udp://<other host>
267
268This outputs:
269
270::
271
272 route-add-accepted prefix=/ndn nexthop=308 origin=static cost=0 flags=child-inherit expires=never
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600273
Alexander Afanasyev84dd4ca2017-10-15 14:56:08 -0400274The ``/ndn`` means that NFD will forward all Interests that start with ``/ndn`` through the
275face to the other host. If you only want to forward Interests with a certain prefix, use it
276instead of ``/ndn``. This only forwards Interests to the other host, but there is no "back
277route" for the other host to forward Interests to you. For that, you can rely on automatic
278prefix propagation feature of NFD or go to the other host and use ``nfdc`` to add the route.
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600279
280Playing with NFD
281----------------
282
283After you haved installed, configured, and started NFD, you can try to install and play
284with the following:
285
286Sample applications:
287
Eric Newberry81a9a862016-12-27 22:59:27 -0700288- `Simple examples in ndn-cxx library <https://named-data.net/doc/ndn-cxx/current/examples.html>`_
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800289
290 If you have installed ndn-cxx from source, you already have compiled these:
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600291
292 + examples/producer
293 + examples/consumer
294 + examples/consumer-with-timer
295
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800296- `Introductory examples of NDN-CCL
Eric Newberry81a9a862016-12-27 22:59:27 -0700297 <https://redmine.named-data.net/projects/application-development-documentation-guides/wiki/Step-By-Step_-_Common_Client_Libraries>`_
Steve DiBenedetto62a93942014-08-24 17:13:52 -0600298
299Real applications and libraries:
300
Junxiao Shiaf9aa362016-07-13 13:18:07 +0000301 + `ndn-tools - NDN Essential Tools <https://github.com/named-data/ndn-tools>`_
Alexander Afanasyev7c10b3b2015-01-20 12:24:27 -0800302 + `ndn-traffic-generator - Traffic Generator For NDN
303 <https://github.com/named-data/ndn-traffic-generator>`_
304 + `repo-ng - Next generation of NDN repository <https://github.com/named-data/repo-ng>`_
305 + `ChronoChat - Multi-user NDN chat application <https://github.com/named-data/ChronoChat>`_
306 + `ChronoSync - Sync library for multiuser realtime applications for NDN
307 <https://github.com/named-data/ChronoSync>`_