| First native version of the NDN protocol written in Javascript ( Also refereed to as CCN ) |
| |
| The goal of this project is to improve the current implementation of the NDN-JS API that allows users to create applications running on top of the NDN network. The goal is to have a lightweight version of the protocol, which can run on browsers. The main intent is to enable browser-based applications to use NDN directly without requiring a binary build of the CCNx code. In particular, the goal is to have an AJAX-style dynamic data access. The goal is also to have a lighter version of the protocol, which would be better suited for embedded systems. Furthermore, the goal is that NDN-JS communicates with CCNx nodes (routers). |
| |
| The current status of NDN-JS allows for JavaScript applications running on browsers to send interest packets and retrieve data packets. This includes encoding and decoding data packets. |
| |
| This is currently done in the following way: |
| |
| var ndn = new NDN(); |
| ndn.transport.connectWebSocket(ndn); |
| |
| var AsyncGetClosure = function AsyncGetClosure() { |
| // Inherit from Closure. |
| Closure.call(this); |
| }; |
| AsyncGetClosure.prototype.upcall = function(kind, upcallInfo) { |
| if (kind == Closure.UPCALL_CONTENT) { |
| console.log("Received " + upcallInfo.contentObject.name.to_uri()); |
| console.log(upcallInfo.contentObject.content); |
| } |
| return Closure.RESULT_OK; |
| }; |
| |
| ndn.expressInterest(new Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt"), new AsyncGetClosure()); |
| |
| *** Firefox extension for the ccnx protocol |
| |
| NDN-JS also includes a Firefox extension for the ccnx protocol. To install, either download |
| https://github.com/remap/ndn-js/blob/master/js/ccnxProtocol.xpi |
| or use js/ccnxProtocol.xpi in the distribution. In Firefox, open |
| Tools > Add-ons. In the "gear" or "wrench" menu, click Install Add-on From File and open |
| ccnxProtocol.xpi. Restart Firefox. |
| |
| Firefox uses the protocol extension to load any URI starting with ccnx, for example |
| ccnx:/ndn/ucla.edu/apps/lwndn-test/trig-table |
| |
| When the page is loaded, Firefox updates the address bar with the full matched name from the |
| retrieved content object including the version, but without the implicit digest or segment number |
| (see below). |
| |
| * Interest selectors in the ccnx protocol |
| |
| You can add interest selectors. For example, this uses 1 to select the "rightmost" child (latest version). |
| ccnx:/ndn/ucla.edu/apps/ndn-js-test/hello.txt?ccnx.ChildSelector=1&key=value#ref |
| |
| The browser loads the latest version and changes the address to: |
| ccnx:/ndn/ucla.edu/apps/ndn-js-test/hello.txt/%FD%05%0B%16z%22%D1?key=value#ref |
| |
| The child selector was used and removed. Note that the other non-ccnx query values and |
| ref "?key=value#ref" are still present, in case they are needed by the web application. |
| |
| The following selector keys are supported: |
| ccnx.MinSuffixComponent= non-negative int |
| ccnx.MaxSuffixComponents= non-negative int |
| ccnx.ChildSelector= non-negative int |
| ccnx.AnswerOriginKind= non-negative int |
| ccnx.Scope= non-negative int |
| ccnx.InterestLifetime= non-negative int |
| ccnx.PublisherPublicKeyDigest= % escaped value |
| ccnx.Nonce= % escaped value |
| |
| TODO: implement ccnx.Exclude. |
| |
| * Multiple segments in the ccnx protocol |
| |
| A URI for content with multiple segments is handled as follows. |
| If the URI has a segment number, just retrieve that segment and return the content to the browser. |
| |
| Otherwise look at the name in the returned ContentObject. If the returned name has no segment number, |
| just return the content to the browser. If the name has a segment number which isn't 0, store it |
| and express an interest for segment 0. Read segments in order and return each content to the browser |
| as we go until we get the segment for FinalBlockID. |
| |