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