简体   繁体   English

在一个线程中定期发送许多 UDP 数据报有时会导致微数据包爆发

[英]Sending regularly many UDP-Datagrams in a thread sometimes results in micro packetbursts

We are trying to send UDP-Datagrams in Android 7.0 per Wifi to a server.我们正在尝试将每个 Wifi 的 Android 7.0 中的 UDP 数据报发送到服务器。 The Datagram-size is 23 Bytes and the frequency is around 15 milliseconds.数据报大小为 23 字节,频率约为 15 毫秒。

We have a Queue into which we put ByteArrays.我们有一个队列,我们​​将 ByteArrays 放入其中。 Another Sending-Thread pulls those Arrays from the threadsafe Queue and sends them in Datgrams through a Datagramsocket to a server.另一个发送线程从线程安全队列中提取这些数组,并通过数据报套接字将它们以数据报的形式发送到服务器。 The socket.send()-method is called every 10-18 ms. socket.send() 方法每 10-18 毫秒调用一次。

The Wireshark on the serverside receives most of the packets in a nice regular stable interval of roughly 15ms, but sometimes (mostly every 150-300 packets) there is a lag of 1-3 sending cycles and then the delayed packets arrive in a "burst" after a pause of 30-60 ms.服务器端的 Wireshark 以大约 15 毫秒的良好的定期稳定间隔接收大部分数据包,但有时(主要是每 150-300 个数据包)有 1-3 个发送周期的滞后,然后延迟的数据包以“突发”的形式到达" 暂停 30-60 毫秒后。

The delays get longer and appear significantly much more often if at runtime we try to put stress on the android phone with Network-Intensive tasks ( when we start a WiFi-Analyser-App ).如果在运行时我们尝试通过网络密集型任务(当我们启动 WiFi-Analyser-App 时)在 android 手机上施加压力,延迟会变得更长并且出现的频率明显更高。

Increasing the ThreadPriority of the Sender-Thread doesn't seem to have any effect on the problem.增加 Sender-Thread 的 ThreadPriority 似乎对问题没有任何影响。

If anybody can help me with some hints on how to have more control over the networkinterface-sending-process in order to reduce the bursts and get a more stable regular sending-interval, me and my mates would be very very thankful.如果有人可以帮助我提供一些关于如何更好地控制网络接口发送过程以减少突发并获得更稳定的定期发送间隔的提示,我和我的伙伴们将非常感激。

Ok .好的 。 We found it out.我们发现了。 The Problems were caused by some of the standard-services in the background like Bluetooth if I remember correctly ( maybe it was also Wifi or GPS, it was quite some time ago to rember correctly ).如果我没记错的话,这些问题是由后台的一些标准服务引起的,比如蓝牙(也许它也是 Wifi 或 GPS,很久以前才能正确记住)。 The service seeked for signals and their strenghts every few seconds, and by doing that disrupted our packetpipeline.该服务每隔几秒钟就会寻找信号及其强度,这样做会破坏我们的数据包管道。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM