How HomeCam Registers NDN Prefixes?
HomeCam, a browser-based home surveillance camera, is one of my major side projects during the past few years. My last post gave an overview on the overall architecture and various components of HomeCam. I mentioned that HomeCam delivers pictures via Named Data Networking (NDN), which provides better scalability because the camera only needs to serve each picture once even if there are multiple viewers, and the network takes care of the distribution.
Both HomeCam viewers and cameras connect to the global NDN testbed network via WebSockets. A viewer sends Interests to the network to request a picture from a specific camera identified by part of the Interest name. The network forwards the Interests to the named camera, and the camera responds with Data packets that contain the picture. But how does the network know where the camera is?
The camera must register its prefix onto the NDN testbed network.
For a regular end host running the NDN Forwarding Daemon (NFD), you may let the world reach your NFD via auto prefix propagation. This procedure involves sending a prefix registration command to the network, which causes the router to add a route toward the end host. A requirement is that the prefix registration command must be signed by a key trusted by the network.
HomeCam camera is a browser-based application that directly connects to a testbed router, and there is no NFD running local to do auto prefix propagation for us. However, HomeCam can still have a route added toward the camera by sending a prefix registration command.
The main obstacle is how to generate a prefix registration command and sign it with a network-trusted certificate. While it is possible to issue your own NDN certificates and have the network trust them, it is difficult to securely store and use these certificates in the browser.
This solution is implemented in four steps:
- The register-prefix-cmd program is used to generate a prefix registration command with specified name prefix and other parameters, and prints the signed command to stdout.
- A signing key is made available to the webserver.
nginx is running as
www-dataand its home directory is
/var/www, so the certificate should be placed there. You may request or import a certificate to this location by prefixing every
sudo HOME=/var/www -u www-data. If you can see the certificate with
sudo HOME=/var/www -u www-data ndnsec list -C, it is installed correctly.
- The HomeCam camera web app uses AJAX to download the signed command from a PHP script.
The PHP script involes
register-prefix-cmdcommand with appropriate arguments, and
passthruthe result to the browser.
- The web app sends the signed command via NDN-JS WebSocket face to the router. If all goes well, this shall bring back a successful response, and the router would add a route toward the WebSocket face where the camera may receive Interests from viewers.
I have been running a camera 24x7 for several weeks, and this "sign elsewhere" prefix registration solution works well most of the time. Same idea can be used in other applications where the app itself is unable to sign its prefix registration commands due to difficulty in key management or limitation in computational resources, but there exists a "secure channel" between the app and a server.