Add ndn-ping example.
diff --git a/js/examples/ndnping/ndn-ping.html b/js/examples/ndnping/ndn-ping.html
new file mode 100644
index 0000000..9327c09
--- /dev/null
+++ b/js/examples/ndnping/ndn-ping.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<!--
+ See COPYING for copyright and distribution information.
+-->
+<html>
+<head>
+<title>NDN Ping</title>
+
+<!--
+ ndn-js.js
+ is a concatented, compressed version of the library,
+ built in tools/build
+-->
+<script type="text/javascript" src="ndn-js.js"></script>
+<script type="text/javascript" src="ndn-ping.js"></script>
+
+</head>
+
+<body>
+
+ <h1>NDN Ping example</h1>
+
+ Using ping responder on NDN testbed, which responds to Interests in <em>
+ /<topo-prefix>/ping/<random-number></em>.
+
+ <h2>NDN Testbed Status</h2>
+ <p>Testbed content ping results retrieved using <a href="http://github.com/remap/ndn-js">NDN.js</a>, a javascript client library for NDN.</p>
+ <table border="0" width="40%" id="pingreport" style="margin-left:20px">
+ </table>
+ <p> </p>
+
+
+</body>
+</html>
diff --git a/js/examples/ndnping/ndn-ping.js b/js/examples/ndnping/ndn-ping.js
new file mode 100644
index 0000000..2aef361
--- /dev/null
+++ b/js/examples/ndnping/ndn-ping.js
@@ -0,0 +1,68 @@
+/*
+ NDN Ping example
+
+ Using ping responder on NDN testbed, which responds to Interests in
+ /<topo-prefix>/ping/<random-number>
+
+ Jeff Burke
+ jburke@remap.ucla.edu
+
+ See COPYING for copyright and distribution information.
+
+*/
+
+ // One of NDN project default hubs
+ hostip="A.ws.ndn.ucla.edu";
+
+ var AsyncGetClosure = function AsyncGetClosure(T0) {
+ this.T0 = T0;
+ Closure.call(this);
+ };
+
+ AsyncGetClosure.prototype.upcall = function(kind, upcallInfo) {
+ if (kind == Closure.UPCALL_FINAL) {
+ // Do nothing.
+ } else if (kind == Closure.UPCALL_INTEREST_TIMED_OUT) {
+
+ nameStr = upcallInfo.interest.name.getName().split("/").slice(0,-2).join("/");
+ document.getElementById('pingreport').innerHTML += '<tr><td width="65%">' + nameStr + ' </td><td align="right">timeout</td></tr>' ;
+ } else if (kind == Closure.UPCALL_CONTENT) {
+ var T1 = new Date();
+ var content = upcallInfo.contentObject;
+ nameStr = content.name.getName().split("/").slice(0,-2).join("/");
+ strContent = DataUtils.toString(content.content);
+ if (strContent=="ping ack") {
+ document.getElementById('pingreport').innerHTML += '<tr><td width="65%">' + nameStr + ' </td><td align="right">' + (T1-this.T0) + ' ms</td></tr>' ;
+ } else {
+ console.log("Unknown content received.");
+ };
+ }
+ return Closure.RESULT_OK;
+ };
+
+ function ping(name) {
+ pingname = name + "/ping/" + Math.floor(Math.random()*100000);
+ ndn.expressInterest(new Name(pingname), new AsyncGetClosure( new Date() ));
+ };
+
+ function dopings() {
+ ping("/ndn/arizona.edu");
+ ping("/ndn/caida.org");
+ ping("/ndn/colostate.edu/netsec")
+ ping("/ndn/memphis.edu/netlab")
+ ping("/ndn/neu.edu/northpole")
+ ping("/ndn/parc.com");
+ ping("/ndn/pku.edu");
+ ping("/ndn/uci.edu");
+ ping("/ndn/ucla.edu");
+ ping("/ndn/ucla.edu/apps");
+ ping("/ndn/uiuc.edu");
+ ping("/ndn/wustl.edu");
+
+ };
+
+ openHandle = function() { dopings(); };
+ var ndn = new NDN({host:hostip, onopen:openHandle});
+ var T0 = 0;
+ ndn.transport.connectWebSocket(ndn);
+