public ElapsedTimeInterval ping(JSONObject header, String hostIP, int port, int timeout, int nTrials) throws Exception{
		try {
			for (int i = 0; i < nTrials; i++){
				ElapsedTime.start("Ping_RPCTotalDelay");
				// send message
				JSONObject args = new JSONObject().put(EchoRPCService.HEADER_KEY, header)
				.put(EchoRPCService.PAYLOAD_KEY, "");

				JSONObject response = RPCCall.invoke(hostIP, port, "echorpc", "echo", args, timeout );

				if ( response == null ) throw new IOException("RPC failed; response is null");
				// examine response
				
				JSONObject rcvdHeader = response.optJSONObject(EchoRPCService.HEADER_KEY);
				
				if ( rcvdHeader == null || !rcvdHeader.has(EchoRPCService.HEADER_TAG_KEY)||
						!rcvdHeader.getString(EchoRPCService.HEADER_TAG_KEY).equalsIgnoreCase(EchoRPCService.RESPONSE_OKAY_STR)){
					throw new IOException("bad response");
				}
				ElapsedTime.stop("Ping_RPCTotalDelay");
			}
		} catch (Exception e) {
			ElapsedTime.abort("Ping_RPCTotalDelay");
			System.out.println("Exception: " + e.getMessage());
		} 
		
		return ElapsedTime.get("Ping_RPCTotalDelay");
	}