改进 UDP 消息处理

发布于 2024-08-03 03:21:39 字数 384 浏览 1 评论 0原文

我有一个 PC 程序通过 UDP 接收来自 20 个定制硬件盒的数据。每个盒子不断地向 PC 上的单个 UDP 套接字发送 UDP 消息。这些消息都包含10-150字节的数据,每个单元在12秒内发送大约20条消息。

测试表明电脑会丢失一些消息。网络上的盒子越少,丢失的消息就越少。

长期的解决方案是在硬件中缓冲数据,并让PC根据需要通过TCP检索数据,但我需要在短期内解决/最小化丢失消息的问题,直到可以部署该解决方案。想法包括: - 升级电脑 - 在传输前过滤掉不必要的消息 - 将硬件中单独的 UDP 消息合并为一个更大的消息 - 在电脑中使用多个套接字来接收消息

我正在寻找有关这些想法的反馈,以及我们可能错过的任何反馈。

接收程序是运行Indy9的C++Builder程序。

I've got a PC program receiving data from 20 custom hardware boxes via UDP. Each of these boxes continually sends UDP messages to a single UDP socket on the PC. The messages all contain 10 - 150 bytes of data, and each unit sends about 20 messages in 12 seconds.

Testing shows that some messages are being missed by the PC. Fewer boxes on the network results in fewer missed messages.

The long term solution is to buffer data in the hardware, and let the PC retrieve data as required via TCP, but I need to solve/minimise the missing message problem in the short term until that solution can be deployed. Ideas include:
- upgrading the PC
- filtering out unnecessary messages before transmission
- combining separate UDP messages in the hardware into a single bigger one
- using multiple sockets in the PC to receive messages

I'm looking for feedback on these ideas, plus any we might have missed.

The receiving program is a C++Builder program running Indy9.

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

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

发布评论

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

评论(3

半透明的墙 2024-08-10 03:21:39

UDP 中丢弃的消息与网络上的 NET 拥塞有关。如果您使用 1 个或 5 个套接字来接收包裹,则没有任何关系。

另外,如果你只有 20 个盒子,则在 12 秒内发送 20 条消息。这意味着每秒只有 33 条消息。对于网络和处理器来说,这确实是微不足道的。

因此,包被丢弃的唯一原因是存在许多其他网络负载。网卡和路由器倾向于选择 tcp-ip 包而不是 udp。

如果没有出现过多的网络负载,则不应丢弃 UDP 数据包。

dropped messages in UDP have to do with the NET congestion on your network. It has nothing to do if you use 1 or 5 sockets to receive the packages.

Also, if you only have 20 boxes, sending 20 messages in 12 seconds. This would mean only 33 messages per second. This is really peanuts... for the network, as well as the processor.

So, the only reason packages are dropped is that there is much other network load going on. Network cards and routers have a tendency to prefer tcp-ip packages above udp.

If there is no excessive network load going on, UDP packages should not be dropped.

夢归不見 2024-08-10 03:21:39

最有可能的问题是在网络上。

您已经说过网络是专用 LAN,这消除了我的建议之一,另一个是确保网络已交换 - 集线器很容易丢失数据包。

如果这没有帮助,那么您可以尝试增加 PC 上的接收缓冲区大小。
http://www.developerweb.net/forum/showthread.php?t= 5773

The most likely problem is on the network.

You've already said the network is private LAN, which eliminates one of my suggestions, the other is to make sure the network is switched - a hub could easily lose packets.

If that doesn't help then you could try increasing the receive buffer size on the PC.
http://www.developerweb.net/forum/showthread.php?t=5773

寄与心 2024-08-10 03:21:39

感谢其他人的建议,但对于任何回头的人来说,这里的解决方案是用正确规格的机器(2GHz Core 2 处理器和 2GB RAM)替换已使用的旧 PC(1.6GHz Celeron 和 512MB RAM)。

Thanks to the other guys for suggestions, but for anybody referring back, the solution here was replacing the old PC that had been used (1.6GHz Celeron with 512MB RAM) with the correct spec machine (2GHz Core 2 processor with 2GB RAM).

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