| cFirst native version of the NDN protocol written in Javascript (also referred 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 ndn protocol |
| |
| NDN.JS also includes a Firefox extension for the ndn protocol. To install, either download |
| https://github.com/remap/ndn-js/blob/master/js/ndnProtocol.xpi |
| or use js/ndnProtocol.xpi in the distribution. In Firefox, open |
| Tools > Add-ons. In the "gear" or "wrench" menu, click Install Add-on From File and open |
| ndnProtocol.xpi. Restart Firefox. |
| |
| Firefox uses the protocol extension to load any URI starting with ndn, for example |
| ndn:/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 ndn protocol |
| |
| You can add interest selectors. For example, this uses 1 to select the "rightmost" child (latest version). |
| ndn:/ndn/ucla.edu/apps/ndn-js-test/hello.txt?ndn.ChildSelector=1&key=value#ref |
| |
| The browser loads the latest version and changes the address to: |
| ndn:/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-ndn 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: |
| ndn.MinSuffixComponent= non-negative int |
| ndn.MaxSuffixComponents= non-negative int |
| ndn.ChildSelector= non-negative int |
| ndn.AnswerOriginKind= non-negative int |
| ndn.Scope= non-negative int |
| ndn.InterestLifetime= non-negative int |
| ndn.PublisherPublicKeyDigest= % escaped value |
| ndn.Nonce= % escaped value |
| |
| TODO: implement ndn.Exclude. |
| |
| * Multiple segments in the ndn 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. |
| |