NFD环境配置以及jndn的安装

本文详细介绍了NFD环境配置的步骤,包括在Ubuntu不同版本上的依赖库安装,如libstdc++6:i386和lib32z1。遇到的错误提示以及解决方案,如建立软连接解决找不到共享库的问题。此外,还强调了解决依赖库对ndn-cxx和nfd的重要性。最后,提到了启动NFD和安装常见客户端库的流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NFD的环境配置是个“有趣的探索”!这么多篇install.md,我TM要看哪一个?不论哪一个都缺失依赖库好嘛T^T被折腾了将近一个月,貌似找到一篇还比较靠谱的安装说明,再加上万能的谷歌和stackoverflow,目前配环境的速度越来越快了~~对于一个天天写bug,随时需要重装系统的人来说,配置环境可是一个很重要的一项基本技能好嘛!!!

废话少说,红色字体是肘子的血泪教训啊。
官方链接:


基于NFD的 Android 应用:https://github.com/YuanKQ/NFD_for_android

Step-By-Step - Common Client Libraries

This document shows step-by-step how to get a minimal NFD running so you can start writing applications to use the NDN Common Client Libraries (NDN-CPPNDN-JSPyNDNjNDN).

Prerequisites

Ubuntu 12.04

In a terminal, enter:

sudo apt-get install build-essential git libssl-dev libsqlite3-dev libcrypto++-dev libpcap-dev libboost1.48-all-dev

Ubuntu 13.10, Ubuntu 14.04 and Ubuntu 15.04

In a terminal, enter:

sudo apt-get install build-essential git libssl-dev libsqlite3-dev libcrypto++-dev libpcap-dev libboost-all-dev 

If you are 64-bit, you must also install libstdc++6:i386 use the command: sudo apt-get install libstdc++6:i386, or you will get the following errors: when you successfully install nfd, and use the commond "nfd-start", you will see "/usr/local/bin/ndnsec: error while loading shared libraries: libndn-cxx.so.0.4.1: cannot open shared object file : no such file or directory".  If you have installed this library, you still can't solve this problem, you may still have to install lib32z1 : sudo apt-get install lib32z1.  
假如还是没有办法解决的话,那就是“no such file or directory”的原因了:建立软连接sudo ln -s /usr/local/lib/libndn-cxx.so.0.4.1 /usr/lib/

肘子在这里可是卡了很久很久啊~说出来都是泪啊~


Attention:
 This step is very import to solve the dependent libraries for ndn-cxx and nfd.

Build/Install NFD

These are steps from build/install NFD which work with the CCL. In a terminal, enter:

git clone https://github.com/named-data/ndn-cxx
git clone --recursive https://github.com/named-data/NFD
cd ndn-cxx
./waf configure

If waf says "program doxygen not found", "program sphinx-build not found" or "library rt not found", it is OK.

./waf
sudo ./waf install
cd ..
cd NFD
./waf configure

If waf says "libndn-cxx not found", then set PKG_CONFIG_PATH as shown in the Prerequisites above.

./waf
sudo ./waf install
cd ..

The NFD programs are installed in /usr/local/bin . The NFD configuration file is in /usr/local/etc/ndn . Copy the sample configuration file to make it the default:

sudo cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf

Ubuntu and Raspbian (Raspberry Pi)

[Ubuntu and Raspbian only] Update the path to the shared libraries:

sudo /sbin/ldconfig

Configure NFD

NFD provides mechanisms to enable strict authorization for all management commands. In particular, one can authorize only a specific public key to create new Faces or to change the strategy choice for specific namespaces. For more information about how to generate a private/public key pair, generate a self-signed certificate, and use this self-signed certificate to authorize NFD management commands, refer to NFD Configuration Tips.

In the sample configuration file, all authorization is disabled, effectively allowing anybody on the local machine to issue NFD management commands. The sample file is intended only for demo purposes and MUST NOT be used in a production environment.

Start NFD

Open a new terminal window (so you can watch the NFD messages) and enter:

nfd-start

On OS X it may ask for your keychain password or ask "nfd wants to sign using key in your keychain." Enter your keychain password and click Always Allow.

Later, you can stop NFD with nfd-stop .

Add a route to another NFD host (optional)

The previous instructions are good for testing on the local host. If you want to route an interest to another NFD host, in a terminal enter:

nfdc register /ndn udp://<other host>

where <other host> is the name or IP address of the other host (e.g., spurs.cs.ucla.edu). The "/ndn" means that NFD will forward all interests that start with /ndn through the face to the other host. If you only want to forward interests with a certain prefix then use it instead of "/ndn".

This only forwards interests to the other host, but there is no "back route" for the other host to forward interests to you. For that, you must go to the other host and use nfdc to add the route. (The "back route" can also be automatically configured with nfd-autoreg. For more information refer to nfd-autoreg manpage.)

Install the Common Client Library

If you haven't done so, get the library from GitHub and follow the INSTALL instructions for your language:

Send an Interest to receive a Data packet

The example program "test get async" is a simple program to send some interests and get a data packet. Here they are on the various languages:

The main calls to the API are (using Python for example):

Call the Face constructor and specify the host.

face = Face("aleph.ndn.ucla.edu")

Create a Name for the Interest, using a Name URI.

name1 = Name("/ndn/edu/ucla/remap/ndn-js-test/howdy.txt")

Call expressInterest, passing in the callbacks for onData and onTimeout.

face.expressInterest(name1, counter.onData, counter.onTimeout)

Start an event loop to keep calling processEvents until the application is finished. Your application should make sure that it calls processEvents in the same thread as expressInterest (which also modifies the pending interest table).

while counter._callbackCount < 3:
    face.processEvents()
    # We need to sleep for a few milliseconds so we don't use 100% of the CPU.
    time.sleep(0.01)

评论 21
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值