Meki Cherkaoui | b7d8eb0 | 2012-04-22 16:25:27 -0700 | [diff] [blame] | 1 | First native version of the NDN protocol written in Javascript ( Also refereed to as CCN ) |
Meki Cherkaoui | f2e96ed | 2012-04-22 16:21:27 -0700 | [diff] [blame] | 2 | |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 3 | 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). |
Meki Cherkaoui | f2e96ed | 2012-04-22 16:21:27 -0700 | [diff] [blame] | 4 | |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 5 | 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. |
Meki Cherkaoui | f2e96ed | 2012-04-22 16:21:27 -0700 | [diff] [blame] | 6 | |
| 7 | This is currently done in the following way: |
| 8 | |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 9 | var ndn = new NDN(); |
Jeff Thompson | b68ceab | 2012-11-25 18:25:56 -0800 | [diff] [blame^] | 10 | ndn.transport.connectWebSocket(ndn); |
| 11 | |
| 12 | var AsyncGetClosure = function AsyncGetClosure() { |
| 13 | // Inherit from Closure. |
| 14 | Closure.call(this); |
| 15 | }; |
| 16 | AsyncGetClosure.prototype.upcall = function(kind, upcallInfo) { |
| 17 | if (kind == Closure.UPCALL_CONTENT) { |
| 18 | console.log("Received " + upcallInfo.contentObject.name.to_uri()); |
| 19 | console.log(upcallInfo.contentObject.content); |
| 20 | } |
| 21 | return Closure.RESULT_OK; |
| 22 | }; |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 23 | |
Jeff Thompson | b68ceab | 2012-11-25 18:25:56 -0800 | [diff] [blame^] | 24 | ndn.expressInterest(new Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt"), new AsyncGetClosure()); |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 25 | |
Jeff Thompson | b68ceab | 2012-11-25 18:25:56 -0800 | [diff] [blame^] | 26 | *** Firefox extension for the ccnx protocol |
| 27 | |
| 28 | NDN-JS also includes a Firefox extension for the ccnx protocol. To install, either download |
| 29 | https://github.com/remap/ndn-js/blob/master/js/ccnxProtocol.xpi |
| 30 | or use js/ccnxProtocol.xpi in the distribution. In Firefox, open |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 31 | Tools > Add-ons. In the "gear" or "wrench" menu, click Install Add-on From File and open |
Jeff Thompson | b68ceab | 2012-11-25 18:25:56 -0800 | [diff] [blame^] | 32 | ccnxProtocol.xpi. Restart Firefox. |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 33 | |
Jeff Thompson | b68ceab | 2012-11-25 18:25:56 -0800 | [diff] [blame^] | 34 | Firefox uses the protocol extension to load any URI starting with ccnx, for example |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 35 | ccnx:/ndn/ucla.edu/apps/lwndn-test/trig-table |
| 36 | |
Jeff Thompson | b68ceab | 2012-11-25 18:25:56 -0800 | [diff] [blame^] | 37 | When the page is loaded, Firefox updates the address bar with the full matched name from the |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 38 | retrieved content object including the version, but without the implicit digest or segment number |
| 39 | (see below). |
| 40 | |
Jeff Thompson | b68ceab | 2012-11-25 18:25:56 -0800 | [diff] [blame^] | 41 | * Interest selectors in the ccnx protocol |
| 42 | |
| 43 | You can add interest selectors. For example, this uses 1 to select the "rightmost" child (latest version). |
| 44 | ccnx:/ndn/ucla.edu/apps/ndn-js-test/hello.txt?ccnx.ChildSelector=1&key=value#ref |
| 45 | |
| 46 | The browser loads the latest version and changes the address to: |
| 47 | ccnx:/ndn/ucla.edu/apps/ndn-js-test/hello.txt/%FD%05%0B%16z%22%D1?key=value#ref |
| 48 | |
| 49 | The child selector was used and removed. Note that the other non-ccnx query values and |
| 50 | ref "?key=value#ref" are still present, in case they are needed by the web application. |
| 51 | |
| 52 | The following selector keys are supported: |
| 53 | ccnx.MinSuffixComponent= non-negative int |
| 54 | ccnx.MaxSuffixComponents= non-negative int |
| 55 | ccnx.ChildSelector= non-negative int |
| 56 | ccnx.AnswerOriginKind= non-negative int |
| 57 | ccnx.Scope= non-negative int |
| 58 | ccnx.InterestLifetime= non-negative int |
| 59 | ccnx.PublisherPublicKeyDigest= % escaped value |
| 60 | ccnx.Nonce= % escaped value |
| 61 | |
| 62 | TODO: implement ccnx.Exclude. |
| 63 | |
| 64 | * Multiple segments in the ccnx protocol |
| 65 | |
Jeff Thompson | 9e6dff0 | 2012-11-04 09:20:47 -0800 | [diff] [blame] | 66 | A URI for content with multiple segments is handled as follows. |
| 67 | If the URI has a segment number, just retrieve that segment and return the content to the browser. |
| 68 | |
| 69 | Otherwise look at the name in the returned ContentObject. If the returned name has no segment number, |
| 70 | just return the content to the browser. If the name has a segment number which isn't 0, store it |
| 71 | and express an interest for segment 0. Read segments in order and return each content to the browser |
| 72 | as we go until we get the segment for FinalBlockID. |
| 73 | |