Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 1 | Getting Started with NFD |
| 2 | ======================== |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 3 | |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 4 | .. _Install NFD Using the NDN PPA Repository on Ubuntu Linux: |
| 5 | |
| 6 | Install NFD Using the NDN PPA Repository on Ubuntu Linux |
| 7 | -------------------------------------------------------- |
| 8 | |
wenkaizheng | 55d83d4 | 2019-08-22 18:36:01 -0700 | [diff] [blame] | 9 | NFD binaries and related tools for the latest versions of Ubuntu Linux can be installed using PPA |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 10 | packages from named-data repository. First, you will need to add ``named-data/ppa`` |
| 11 | repository to binary package sources and update list of available packages. |
| 12 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 13 | Preliminary steps if you have not used PPA packages before |
| 14 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 15 | |
| 16 | To simplify adding new PPA repositories, Ubuntu provides ``add-apt-repository`` tool, |
Davide Pesavento | cc7bee7 | 2016-04-22 02:21:13 +0200 | [diff] [blame] | 17 | which is not installed by default on some systems. |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 18 | |
| 19 | :: |
| 20 | |
| 21 | sudo apt-get install software-properties-common |
| 22 | |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 23 | Adding NDN PPA |
| 24 | ~~~~~~~~~~~~~~ |
| 25 | |
| 26 | After installing ``add-apt-repository``, run the following command to add `NDN PPA |
| 27 | repository`_. |
| 28 | |
| 29 | :: |
| 30 | |
| 31 | sudo add-apt-repository ppa:named-data/ppa |
| 32 | sudo apt-get update |
| 33 | |
| 34 | Installing NFD and other NDN packages |
| 35 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 36 | |
| 37 | After you have added `NDN PPA repository`_, NFD and other NDN packages can be easily |
| 38 | installed in a standard way, i.e., either using ``apt-get`` as shown below or using any |
| 39 | other package manager, such as Synaptic Package Manager: |
| 40 | |
| 41 | :: |
| 42 | |
| 43 | sudo apt-get install nfd |
| 44 | |
| 45 | For the list of available packages, refer to `NDN PPA repository`_ homepage. |
| 46 | |
| 47 | .. _NDN PPA repository: https://launchpad.net/~named-data/+archive/ppa |
| 48 | |
| 49 | Building from Source |
| 50 | -------------------- |
| 51 | |
| 52 | Downloading from Git |
| 53 | ~~~~~~~~~~~~~~~~~~~~ |
| 54 | |
| 55 | The 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 |
Alexander Afanasyev | fb03421 | 2020-01-07 15:05:18 -0500 | [diff] [blame] | 57 | sure you checkout the correct release tag (e.g., ``*-0.7.0``) for both repositories: |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 58 | |
| 59 | :: |
| 60 | |
| 61 | # Download ndn-cxx |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 62 | git clone https://github.com/named-data/ndn-cxx |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 63 | |
| 64 | # Download NFD |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 65 | git clone --recursive https://github.com/named-data/NFD |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 66 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 67 | .. 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 Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 72 | Prerequisites |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 73 | ~~~~~~~~~~~~~ |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 74 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 75 | Install the `ndn-cxx library <https://named-data.net/doc/ndn-cxx/current/INSTALL.html>`__ and its requirements |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 76 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 77 | - On macOS with Homebrew: |
Junxiao Shi | e5e1e25 | 2014-12-13 22:07:35 -0700 | [diff] [blame] | 78 | |
| 79 | :: |
| 80 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 81 | brew install boost openssl pkg-config |
Junxiao Shi | e5e1e25 | 2014-12-13 22:07:35 -0700 | [diff] [blame] | 82 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 83 | - On Ubuntu: |
Junxiao Shi | e5e1e25 | 2014-12-13 22:07:35 -0700 | [diff] [blame] | 84 | |
| 85 | :: |
| 86 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 87 | sudo apt-get install build-essential pkg-config libboost-all-dev \ |
| 88 | libsqlite3-dev libssl-dev libpcap-dev |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 89 | |
| 90 | To build manpages and API documentation: |
| 91 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 92 | - On macOS with Homebrew: |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 93 | |
| 94 | :: |
| 95 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 96 | brew install doxygen graphviz |
| 97 | sudo easy_install pip |
| 98 | sudo pip Sphinx |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 99 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 100 | - On Ubuntu: |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 101 | |
| 102 | :: |
| 103 | |
| 104 | sudo apt-get install doxygen graphviz python-sphinx |
| 105 | |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 106 | Build |
| 107 | ~~~~~ |
| 108 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 109 | The following basic commands should be used to build NFD on Ubuntu and macOS with Homebrew: |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 110 | |
| 111 | :: |
| 112 | |
| 113 | ./waf configure |
| 114 | ./waf |
| 115 | sudo ./waf install |
| 116 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 117 | If you have installed ``ndn-cxx`` library and/or other dependencies into a non-standard path, you |
Alexander Afanasyev | 6db058c | 2014-11-13 16:46:25 -0800 | [diff] [blame] | 118 | may need to modify ``PKG_CONFIG_PATH`` environment variable before running ``./waf configure``. |
| 119 | For example, |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 120 | |
| 121 | :: |
| 122 | |
Alexander Afanasyev | 6db058c | 2014-11-13 16:46:25 -0800 | [diff] [blame] | 123 | export PKG_CONFIG_PATH=/custom/lib/pkgconfig:$PKG_CONFIG_PATH |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 124 | ./waf configure |
| 125 | ./waf |
| 126 | sudo ./waf install |
| 127 | |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 128 | Refer to ``./waf --help`` for more options that can be used during ``configure`` stage and |
| 129 | how to properly configure and run NFD. |
| 130 | |
Alexander Afanasyev | 508411e | 2014-12-16 13:27:59 -0800 | [diff] [blame] | 131 | .. 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 Afanasyev | 2618153 | 2014-05-07 23:38:51 -0700 | [diff] [blame] | 136 | Debug symbols |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 137 | ~~~~~~~~~~~~~ |
Alexander Afanasyev | 2618153 | 2014-05-07 23:38:51 -0700 | [diff] [blame] | 138 | |
| 139 | The default compiler flags enable debug symbols to be included in binaries. This |
| 140 | potentially allows more meaningful debugging if NFD or other tools happen to crash. |
| 141 | |
| 142 | If it is undesirable, default flags can be easily overridden. The following example shows |
| 143 | how to completely disable debug symbols and configure NFD to be installed into ``/usr`` |
| 144 | with configuration in ``/etc`` folder. |
| 145 | |
| 146 | :: |
| 147 | |
| 148 | CXXFLAGS="-O2" ./waf configure --prefix=/usr --sysconfdir=/etc |
| 149 | ./waf |
| 150 | sudo ./waf install |
| 151 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 152 | .. note:: |
| 153 | For Ubuntu PPA packages debug symbols are available in ``*-dbg`` packages. |
| 154 | |
Alexander Afanasyev | 7c10b3b | 2015-01-20 12:24:27 -0800 | [diff] [blame] | 155 | Customize Compiler |
| 156 | ~~~~~~~~~~~~~~~~~~ |
| 157 | |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 158 | To choose a custom C++ compiler for building NFD, set the ``CXX`` environment variable |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 159 | to point to the compiler binary. For example, to select the clang compiler on a Linux |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 160 | system, use the following: |
Alexander Afanasyev | 7c10b3b | 2015-01-20 12:24:27 -0800 | [diff] [blame] | 161 | |
| 162 | :: |
| 163 | |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 164 | CXX=clang++ ./waf configure |
Alexander Afanasyev | 7c10b3b | 2015-01-20 12:24:27 -0800 | [diff] [blame] | 165 | |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 166 | Building documentation |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 167 | ~~~~~~~~~~~~~~~~~~~~~~ |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 168 | |
| 169 | NFD 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 DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 183 | Manpages are automatically created and installed during the normal build process (e.g., |
| 184 | during ``./waf`` and ``./waf install``), if ``python-sphinx`` module is detected during |
| 185 | ``./waf configure`` stage. By default, manpages are installed into |
Alexander Afanasyev | 284257b | 2014-04-11 14:16:51 -0700 | [diff] [blame] | 186 | ``${PREFIX}/share/man`` (where default value for ``PREFIX`` is ``/usr/local``). This |
| 187 | location can be changed during ``./waf configure`` stage using ``--prefix``, |
| 188 | ``--datarootdir``, or ``--mandir`` options. |
| 189 | |
| 190 | For more details, refer to ``./waf --help``. |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 191 | |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 192 | Initial 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 | |
| 199 | General |
| 200 | ~~~~~~~ |
| 201 | |
| 202 | After installing NFD from source, you need to create a proper config file. If default |
| 203 | location for ``./waf configure`` was used, this can be accomplished by simply copying the |
| 204 | sample configuration file: |
| 205 | |
| 206 | :: |
| 207 | |
| 208 | sudo cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf |
| 209 | |
| 210 | NFD Security |
| 211 | ~~~~~~~~~~~~ |
| 212 | |
| 213 | NFD provides mechanisms to enable strict authorization for all management commands. In |
| 214 | particular, one can authorize only specific public keys to create new Faces or change the |
| 215 | forwarding strategy for specific namespaces. For more information about how to generate |
| 216 | private/public key pair, generate self-signed certificate, and use this self-signed |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 217 | certificate to authorize NFD management commands, refer to :ref:`How to configure NFD |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 218 | security` FAQ question. |
| 219 | |
| 220 | In the sample configuration file, all authorizations are disabled, effectively allowing |
| 221 | anybody on the local machine to issue NFD management commands. **The sample file is |
| 222 | intended only for demo purposes and MUST NOT be used in a production environment.** |
| 223 | |
| 224 | Running |
| 225 | ------- |
| 226 | |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 227 | Starting |
| 228 | ~~~~~~~~ |
| 229 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 230 | If you have installed NFD from source code, it is recommended to start NFD with the |
| 231 | ``nfd-start`` script: |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 232 | |
| 233 | :: |
| 234 | |
| 235 | nfd-start |
| 236 | |
Junxiao Shi | 849e12a | 2017-08-02 00:14:57 +0000 | [diff] [blame] | 237 | On macOS it may ask for your keychain password or ask ``nfd wants to sign using key in |
Davide Pesavento | 2849fd4 | 2019-01-03 18:30:05 -0500 | [diff] [blame] | 238 | your keychain``. Enter your keychain password and click "Always Allow". |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 239 | |
| 240 | Later, you can stop NFD with ``nfd-stop`` or by simply killing the ``nfd`` process. |
| 241 | |
Davide Pesavento | 2849fd4 | 2019-01-03 18:30:05 -0500 | [diff] [blame] | 242 | If you have installed NFD using a package manager, you can start and stop NFD using the |
| 243 | operating system's service manager (such as systemd or launchd) or using |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 244 | "Automatically start NFD" option in NDN Control Center app. |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 245 | |
| 246 | Connecting to remote NFDs |
| 247 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 248 | |
Junxiao Shi | 849e12a | 2017-08-02 00:14:57 +0000 | [diff] [blame] | 249 | To create a UDP tunnel to a remote NFD, execute the following command in terminal: |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 250 | |
| 251 | :: |
| 252 | |
Junxiao Shi | 849e12a | 2017-08-02 00:14:57 +0000 | [diff] [blame] | 253 | nfdc face create udp://<other host> |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 254 | |
| 255 | where ``<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 Shi | 849e12a | 2017-08-02 00:14:57 +0000 | [diff] [blame] | 260 | face-created id=308 local=udp4://10.0.2.15:6363 remote=udp4://131.179.196.46:6363 persistency=persistent |
| 261 | |
| 262 | To 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 | |
| 268 | This outputs: |
| 269 | |
| 270 | :: |
| 271 | |
| 272 | route-add-accepted prefix=/ndn nexthop=308 origin=static cost=0 flags=child-inherit expires=never |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 273 | |
Alexander Afanasyev | 84dd4ca | 2017-10-15 14:56:08 -0400 | [diff] [blame] | 274 | The ``/ndn`` means that NFD will forward all Interests that start with ``/ndn`` through the |
| 275 | face to the other host. If you only want to forward Interests with a certain prefix, use it |
| 276 | instead of ``/ndn``. This only forwards Interests to the other host, but there is no "back |
| 277 | route" for the other host to forward Interests to you. For that, you can rely on automatic |
| 278 | prefix propagation feature of NFD or go to the other host and use ``nfdc`` to add the route. |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 279 | |
| 280 | Playing with NFD |
| 281 | ---------------- |
| 282 | |
| 283 | After you haved installed, configured, and started NFD, you can try to install and play |
| 284 | with the following: |
| 285 | |
| 286 | Sample applications: |
| 287 | |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 288 | - `Simple examples in ndn-cxx library <https://named-data.net/doc/ndn-cxx/current/examples.html>`_ |
Alexander Afanasyev | 7c10b3b | 2015-01-20 12:24:27 -0800 | [diff] [blame] | 289 | |
| 290 | If you have installed ndn-cxx from source, you already have compiled these: |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 291 | |
| 292 | + examples/producer |
| 293 | + examples/consumer |
| 294 | + examples/consumer-with-timer |
| 295 | |
Alexander Afanasyev | 7c10b3b | 2015-01-20 12:24:27 -0800 | [diff] [blame] | 296 | - `Introductory examples of NDN-CCL |
Eric Newberry | 81a9a86 | 2016-12-27 22:59:27 -0700 | [diff] [blame] | 297 | <https://redmine.named-data.net/projects/application-development-documentation-guides/wiki/Step-By-Step_-_Common_Client_Libraries>`_ |
Steve DiBenedetto | 62a9394 | 2014-08-24 17:13:52 -0600 | [diff] [blame] | 298 | |
| 299 | Real applications and libraries: |
| 300 | |
Junxiao Shi | af9aa36 | 2016-07-13 13:18:07 +0000 | [diff] [blame] | 301 | + `ndn-tools - NDN Essential Tools <https://github.com/named-data/ndn-tools>`_ |
Alexander Afanasyev | 7c10b3b | 2015-01-20 12:24:27 -0800 | [diff] [blame] | 302 | + `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>`_ |