I need to calculate the following:
Could someone please tell me what is the best way to track these things?
I need accuracy to be high.
please find the code to get latency.and mark it as solution if it solve your problem ,so that it helps the other to find the answer.
public String getLatency()
{
String latency ="";
String ip = "ip address of the server";
String pingCmd = "ping -c 25 " + ip;
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec(pingCmd);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inputLine;
String latencyResult = null;
while ((inputLine = in.readLine()) != null)
{
latencyResult = inputLine;
}
String[] keyValue = latencyResult.split("=");
String[] value = keyValue[1].split("/");
latency = value[1];
}
catch (Exception e)
{
LogWrite.d(TAG, "Exception..."+e);
}
return latency ;
}`