1

I'm developing an app that analyses the quality of your internet connection, and part of that is measuring packet loss.

I was thinking of sending packages to an IP address, but how can I send messages and check that they return? I'm guessing I need to send a package prompting a reply, but I can't find an example of that using either search or Google.

Or should I use existing traffic(how?)?

Besides that, how do I measure round trip time?

2 Answers2

1

As TCP is reliable transport, you don't see dropped packets. In Linux you can use ifconfig to see how many retransmits you incurred. I am not sure what command line tools would show you this on Android, but you would need to use a system tools to give you this information.

BTW You can estimate the packet loss using UDP packets.The packets loss rate for UDP and TCP is not the same but it gives you an idea.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

You'll need to use UDP, or ICMP (ping) for this as you won't be able to see TCP packet loss easily.

If you use ICMP you'll need to ensure the opposite computer responds to ICMP. Firewalls often block ICMP.

If you use UDP the other computer will need server software which can recognize your packets and reply as quickly as possible. The simpliest type of server for this would be called an Echo Server.

Here's a Java UDP Echo Server

Round trip time can be measured by taking the difference between the time you transmit a packet to the time you receive a reply for that transmission. Your protocol should be trivial so as not to pollute roundtrip time with processing time.

William Morrison
  • 10,953
  • 2
  • 31
  • 48