测量数据包丢失与Java数据包、测量、Java

2023-09-07 23:37:05 作者:_少年很平凡、

我正在开发一个应用程序,它通过分析网络连接的质量,其中的一部分是测量数据包丢失。

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

我想包发送到一个IP地址,但我怎么能发送消息,并检查他们返回?我猜我需要发送一个包提示的答复,但我不能找到一个很好的例子无论是使用搜索或谷歌。

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?

推荐答案

由于TCP是可靠的运输,你没有看到丢弃的数据包。在Linux中,你可以用ifconfig看看有多少你重发发生。我不知道是什么命令行工具会告诉你该在Android上,但你需要使用的系统工具给你这些信息。

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.

顺便说一句,您可以估算使用UDP packets.The丢包率的UDP和TCP是不一样的,但它给你一个想法丢包。

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.