/* 
	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
		var hostip = "B.ws.ndn.ucla.edu";

		var AsyncGetClosure = function AsyncGetClosure(T0) {
			this.T0 = T0;
			Closure.call(this);
		};
		
    AsyncGetClosure.gotFirstUpcall = false;
		AsyncGetClosure.prototype.upcall = function(kind, upcallInfo) {
      if (!AsyncGetClosure.gotFirstUpcall) {
        AsyncGetClosure.gotFirstUpcall = true;
        dopings();
      }
      
			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/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");
		};
		
		var ndn = new NDN({host:hostip});
		var T0 = 0;
    // Do the first ping to get started.  The remaining pings are requested on the first upcall.
    ping("/ndn/arizona.edu");
