Get NFD Connected

UPDATE 2021-06-01: nfdc command syntax changed since NFD 0.6.0. This article has been updated to include the new syntax.

Named Data Networking (NDN) is a potential future Internet architecture designed as a distribution network. My last post described how to deploy NDN Forwarding Daemon (NFD) on a low end box. Now it's time to get it connected.

The procedures and experiences in this post are applicable to any NDN node. If you aren't using a low end box, you may follow the official guide to install binary packages or compile from source. This post assumes you have ndn-cxx, nfd, and ndnping installed. You need access to two machines with NFD running; they are referred to as "local" and "remote".

Connect to Another Machine

After installing NFD on your machine, you can connect to any other machine running NFD. Although NDN can run natively above Ethernet, there isn't a global scale native NDN network yet because NDN is still in its early stage. Instead, NDN can run as an overlay network above traditional IP network. You can specify the IP address and port number of the remote NFD, so that NDN packets are encapsulated into UDP or TCP packets and sent to the remote NFD.

Deploy NDN Forwarding Daemon in Low End Box

Named Data Networking (NDN) is a future Internet architecture designed as a distribution network. To access NDN network from a Linux or OSX machine, one can install NDN Platform, a collection of software packages including the protocol stack and critical applications. NDN Forwarding Daemon (NFD), a core component of the architecture, serves as a software router and runs both on network routers as well as on end hosts to communicate with routers.

NDN Platform has new version releases periodically, and binary packages are provided with each platform release. However, the development of NDN software, including NFD, happens much faster than platform releases. If one wants to run bleeding edge software, those packages must be built from source code available on GitHub.

As a geeky low end box user, I'm thinking: can I run NDN platform on a Linux box with a small amount of memory? The box I'm talking about is an OpenVZ container from LowEndSpirit UK location, with only 128MB memory and no swap space. To make the challenge more interesting, I want to avoid apt-get, and run bleeding edge version built from source code.

Building on the Box

I quickly installed compilers and dependencies (such as libboost-all-dev which takes several minutes to download) with apt-get, and cloned the git repositories for NFD and other essential NDN Platform packages. Given that the box has small memory and slow CPU, I can expect the compilation process to take a few hours, just like 8 years ago when I was compiling Apache on a library computer.

Faster Content Distribution with Content Addressable NDN Repository

The effectiveness of universal caching in Named Data Networking depends on data naming. NDN routers cannot identify duplicate contents published under different Names. This paper proposes an enhancement to NDN repository so that duplicate contents could be identified by their hash, in order to save bandwidth and shorten download completion time. The repository indexes Data packets not only by Name, but also by hash of payload. Client applications could retrieve chunks by hash from a nearby neighbor. Therefore, the same payload does not have to traverse the Internet twice. Our evaluation shows that total download time for two Linux Mint disc images is reduced by up to 38%.

Download full report as PDF
Browse code repository

Build a Free SMS Robot with Google Voice

I have been look for a free SMS API since April, when my previous free SMS provider, IMified, announced its shutdown.

Zeep Mobile claims to be free forever (because it is ad-supported), but my sign-up is unanswered after a few weeks. Twilio and Tropo both give developers some free credit, but they charge money for production use. Other resources are suggesting an in-house solution: buy a SIM card with cheap / unlimited text plan, plug it into an old phone, and connect to the server; this still costs money, and is impossible for those using a VPS.

As a Google Voice user, I'm thinking: can I use Google Voice to build a free SMS robot?

Google Voice API

Google, the company who release an API for almost every product, does not provide a Google Voice API.

那些年,我做过的网站

2001年,我制作了第一个个人主页。10年过去了,让我来回顾一下,10年来我做过的网站。

以下列举了34个网站,只包含目前仍然在线、或者能够找到截图/源码的站点,且不包含某些非公开项目;实际做过的网站,大约在60个左右。部分截图来自Internet Archive Wayback Machine

2001 个人主页

  • 内容:自我介绍,我的第一张数码照片
  • 技术:FrontPage
  • 发布:通过电子邮件发给读者
个人主页 截图

2002 FredSoft

  • 内容:VB编程作品
  • 技术:手写HTML4
  • 发布:学校空间
FredSoft 截图

2002 个人文件夹

  • 内容:链接到子文件夹
  • 技术:手写HTML4、CSS、JavaScript
  • 发布:本地计算机个人使用,Windows 98的folder.htt功能
个人文件夹 截图

How do I deploy my website on NDN?

As a website owner, I'm always thinking about making my website available on more channels, so I enabled IPv6 several years ago. NDN comes to my eye as a new "content distribute model" and "communicate protocol". It's natural for me to think about: how do I deploy my website on NDN?

Like most small websites, my website runs mainly on HTTP. Visitors issue GET requests to retrieve pages and resources, which is essentially static but may change at any time. They issue POST requests to interact with web applications, or play with JavaScript-based web applications. I used to provide file downloading through FTP or BitTorrent (but it's now on SkyDrive). I'm collecting statistics with Google Analysis, and an accurate report is important to me. To sum up, I have 5 scenarios:

  1. retrieve pages and resources;
  2. server-based web applications;
  3. JavaScript-based web application;
  4. file downloading;
  5. analysis.

File downloading is the easiest one on NDN. Once a file is published, I would not modify it without using a new name. So, publishing files under a NDN prefix is sufficient. By adding a segmentation component in data names, visitors can download a piece of a file, which is similar to BitTorrent.

Retrieving pages and resources is similar to file downloading, except that pages may change at any time. I don't know when a page will change, so I cannot specify an expiry time when the page was served. In HTTP, user agents can include a If-Modified-Since header, and server would respond with 304 status code if page is not modified without sending the content. In NDN, I can add a version component in data names, so user agents can INTEREST locally-cached version number with RightmostRightSibling annotation.

纯真IP数据库批量查询

纯真IP数据库(qqwry.dat)批量查询PHP脚本,qqwry.lib.php。此脚本适合一次性查询大量IP地址的归属地,比如在几万行的网站日志文件中添加IP归属地。

下载纯真IP数据库批量查询PHP脚本

使用前请获取纯真IP数据库存储qqwry.dat于同一目录。

接口使用示例

require 'qqwry.lib.php';
$qqwry=new QQWRY;
$ip_arr=array();
$ip_arr[]=ip2long('8.8.8.8');
$ip_arr[]=ip2long('10.0.0.1');
$results=$qqwry->query($ip_arr);
foreach ($results as $ip=>$record) {
    echo long2ip($ip).' '.$record->get_c().' '.$record->get_a()."\n";
}

10分钟为网站添加聊天室功能

2016-01-05更新:Windows Live Messenger Connect已于2013年关闭,本技巧已经失效。

如果你正在运营一家新闻/小说/视频类网站,每时每刻都有大量用户访问同一个页面,那么你可以在网页上添加一个“聊天室”,让同时访问同一网页的用户互相交流。

根据本文介绍的方法,你可以在10分钟为网站添加聊天室功能,而且不占用任何服务器资源。

第一步:应用注册(3分钟)

本文介绍的“聊天室”功能由Windows Live Messenger Connect提供,需要使用一个Windows Live ID来管理。如果你的网站不是个人网站,建议你新注册一个Windows Live ID作为开发者帐号,以便在必要时与其他网站管理者共同使用该帐号。注意密码必须足够复杂,否则是无法作为开发者帐号使用的。

在服务器上用Fiddler抓取HTTPS流量

开发互联网应用的过程中,常常会设立或利用网络接口。为了调试对网络接口的使用,往往需要查看流入和流出网络接口的网络流量或数据包。“抓包工具”就是一类用于记录通过网络接口的数据的工具。

我们知道,网络协议是分层设计的,OSI模型将网络协议分为了7个层次。不同的抓包工具,可以在网络协议的不同层次上工作。常用的Wireshark就是一种在网络层上工作的抓包工具,不仅自带大量的协议分析器,而且可以通过编写Wireshark插件来识别自定义的协议。虽然Wireshark功能强大,但是却并不能解决所有的抓包问题,其原因在于:

  • Wireshark工作在网络层;如果计算机配置了IPSec传输层加密,则在网络层的流量都已经被加密,什么也看不到。
  • 当今大量网络接口使用HTTPS加密,Wireshark不能抓取到HTTPS流量的明文内容。

那么,如何抓取到HTTPS请求的明文内容呢?使用Fiddler就可以办到。

Fiddler是Eric Lawrence编写的HTTP抓包软件。Fiddler工作在应用层上,作为其他程序的HTTP代理服务器。它可以直接抓取并分析HTTP流量,也可以作为“中间人”抓取并分析HTTPS流量。

如何使用FiddlerCap抓取网站访问记录

感谢你汇报了有关我的网站或作品的一个问题。为了定位你的问题原因、并尽快解决这个问题,我请求你根据下列步骤抓取一份网站访问记录。

  1. 下载FiddlerCap,并保存在桌面上
  2. 请关闭除了本页之外的所有浏览器窗口或标签页
  3. 双击桌面上的FiddlerCapSetup.exe文件,单击Install按钮
    安装界面
  4. 安装完毕后,单击Close按钮
    安装完毕界面
    此时如果弹出0xc0000135错误,请下载安装.NET Framework 2.0
  5. 如果我要求你“抓取HTTPS流量”,请勾选Decrypt HTTPS traffic(弹出A note about HTTPS Decryption对话框请单击OK);勾选此选项后,浏览器访问https网站时会弹出证书错误警告,请忽略那些警告
  6. 依次单击Clear Cookies、Clear Cache、1 Start Capture按钮
    主界面-未开始
  7. 如果你使用的浏览器不是IE,请手动将HTTP代理服务器设置成127.0.0.1、端口号8889
  8. 打开浏览器窗口,访问遇到问题的网页并进行必要的操作,使你汇报的问题再次出现
  9. 回到FiddlerCap窗口,依次单击2 Stop Capture、3 Save Capture按钮
    主界面-已抓取
  10. 在Save Session Capture to...对话框中,将网站访问记录.saz文件保存在桌面上
  11. 访问阳光男孩的网上名片查看我的Email地址,并把问题描述、截图、网站访问记录发送给我。
    阳光男孩尊重你的隐私,你提交的网站访问记录只会用于问题的定位和解决,不作其他用途。

说明:FiddlerCap是Eric Lawrence编写的HTTP访问记录抓取软件。 本文面向熟悉计算机基本操作的读者,介绍了该软件的基本使用方法,让你在汇报问题时提供更多信息,用于问题的定位和解决。