VenushkaT
VenushkaT

Reputation: 1158

Calculate download speeds/packet loss /jitter /latency to servers on all the continents values (Android)

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.

Upvotes: 1

Views: 1932

Answers (1)

User10001
User10001

Reputation: 1305

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 ;                    
             }`

Upvotes: 4

Related Questions