Android 蓝牙的吞吐量行为

发布于 2024-12-10 16:07:47 字数 884 浏览 0 评论 0原文

为了检查吞吐量,我修改了蓝牙聊天示例。

  1. 我在 UI 中提供了一个发送按钮,用于发送一些预定义的号码。字节到服务器套接字并等待确认

  2. ServerSocket 等待某个字符串,一旦获得数据,就会通过发送确认进行回复。

我对此连接的吞吐量计算如下。

  1. 我记录发送数据的开始时间。

  2. 收到确认后,我记录结束时间。

  3. 因此吞吐量将为(发送的数据大小 + 收到的确认大小)/ 所花费的时间。

结果是:

dataSent(KB)-------------------Throughput(Kilo bits per second)

1KB                         ~200Kbps

5KB                         ~560Kbps 

10KB                        ~688Kbps

50KB                        ~512Kbps

根据从应用程序获取的一些数据 行为是低数据量例如 1 KB 或 5 KB 吞吐量较小。它会增加到 40KB 左右,但在 50KB 左右之后又开始减少。我可以看到接收端发生了一些垃圾收集,这增加了延迟。

我想知道这是否是正确的行为。为什么对于较少的数据(如 1KB 或 5 KB),吞吐量会减少,然后会增加。我可以考虑哪些事实会增加延迟。现在,当发送方收到来自接收方的确认时,计算吞吐量(其完整的往返计算)。我可以像发送数据一样进行单程,并在接收到所有内容后计算接收器中的吞吐量吗?我尝试了这个,但两部手机之间存在毫秒差异,这给我带来了错误的结果,有时会出现负值。 请帮助我理解正确的行为。

To check the throughput i have modified the bluetooth chat example.

  1. I have provided a Send button in the UI which send some predefined no. of bytes to the server socket and waits for Acknowledgement

  2. The ServerSocket waits for some string and once it gets the data it replies by sending Acknowledgement.

Here Throughput for this connection I have calculated as follows.

  1. I record the start time when the data is sent.

  2. ON receiving of the Acknowledgement i record the end time.

  3. So throughput will be (data sent size + ack received size) / time taken.

The results are:

dataSent(KB)-------------------Throughput(Kilo bits per second)

1KB                         ~200Kbps

5KB                         ~560Kbps 

10KB                        ~688Kbps

50KB                        ~512Kbps

According some of the data got from the application The behavior is that for low data like 1 KB or 5 KB throughput is less. It increases till around 40KB or but again after 50 KB or so it starts decreasing. I can see some garbage collection happening in the receiving side, this adds to the delay.

I want to know if this is the right behavior. why for less data like 1KB or 5 KB throughput less and then it increases. What are the facts that i can consider which can add to the delay. Now the throughput is calculated when the sender receives the Acknowledgement from the receiver(Its full round trip calculation). Can I make it single trip like sending of data and after receiving everything I calculate throughput in the receiver. I tried this but there was milliseconds difference in the two phone which gave me wrong results some time negative value.
Please help me in understanding the correct behavior.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹雪碎 2024-12-17 16:07:47

一个可能的因素是蓝牙执行一些动态适应,可以允许连接随着时间的推移而改善并增加有效吞吐量。

1) 自适应跳频 (AFH):由于 BT 使用与 WiFi 相同的 2.4GHz 频谱,因此 WiFi 流量可能会破坏某些 BT 通道并导致重新传输。 BT 设备会随着时间的推移检测干扰,并不断重新协商所使用的频率以避免干扰。

2) 信道质量驱动的动态数据速率 - BT 设备动态改变物理数据速率,以便通过调整高速率/低可靠性与低速率/高可靠性数据包的使用来找到最佳吞吐量。

这些类型的算法可以使吞吐量随着时间的推移而变得更好。

One possible factor is that Bluetooth performs some dynamic adaptation that can allow the connection to improve over time and increase the effective throughput.

1) Adaptive frequency hopping (AFH): Since BT uses the same 2.4GHz spectrum as wifi, you can have wifi traffic that clobbers some BT channels and causes retransmissions. BT devices detect the interference over time and constantly re-negotiate the frequencies they use to avoid interference.

2) Channel quality driven dynamic data rate - BT devices dynamically change the physical data rate in order to find the best throughput by adjusting the use of high rate/low reliability vs lower rate/higher reliability packets.

These types of algorithms can cause the throughput to get better over time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文