负载下的 UDP 组播性能

发布于 2024-08-10 03:29:50 字数 431 浏览 5 评论 0原文

我有一个简单的 C# 应用程序,它在单接收方、单发送方场景中使用 UDP 多播。目标是在本地网络环境中尽可能快地传递消息。

我使用过 SocketAsyncEventArgs/SendAsync/ReceiveAsync、BeginSend/BeginReceive、Threads/Send/Receive,并尝试过 PGM 和 UDP 多播。

每次实施尝试都可以通过本地发送、本地接收重复传递消息,最多可达 1000 条左右。之后,性能开始呈指数下降。 1000 条消息只需要百分之几秒,而 10,000 条消息可能需要 2-10 秒。

有人有高性能 UDP/PGM 组播的经验吗?获得最大吞吐量的最佳设计是什么?

更新

现在,它只是一个本地运行的程序 - 1 个应用程序,1 个发送器和 1 个接收器。测试消息为 4 个字节。

I have a simple C# application that uses UDP multicast in a single-receiver, single-sender scenario. The goal is to get message delivery as fast as possible in a local network environment.

I have used SocketAsyncEventArgs/SendAsync/ReceiveAsync, BeginSend/BeginReceive, Threads/Send/Receive, and have tried both PGM and UDP multicast.

Each implementation attempt works OK for repeated message delivery up to around 1000 messages with local send, local receive. After that, the performance starts to drop exponentially. Where 1000 messages take a few hundredths of a second, 10,000 messages might take anywhere from 2-10 seconds.

Does anyone have experience in high-performance UDP/PGM multicasting? What is the best design to get maximum throughput?

Update

Right now, it's just a single program running locally - 1 application with 1 sender and 1 receiver. The test messages are 4 bytes.

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

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

发布评论

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

评论(2

彩扇题诗 2024-08-17 03:29:50

尝试使套接字的发送或接收缓冲区(服务器或客户端)足够大,以容纳您期望处理的流量。以下是我自己的 UDP 多播服务器/客户端在服务器端的一些示例 C# 代码,其中 dataSock 是绑定到 UDP 多播组的 Socket

dataSock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, (NumberOfPackets * PacketSize) + SmallEpsilonForExtraHeadroom);

另外请确保并设置 < code>SocketOptionName.SendBuffer 在客户端,以匹配服务器生成的缓冲区大小。

如果您还不知道的话,我还建议您使数据包大小小于 MTU。默认情况下,MTU 设置为 1500 字节。 (MTU 是最大传输单元大小)

除非您还限制发送速率,以确保您的客户端能够跟上,否则您仍然可能会丢失数据包。您的网络硬件很可能不是这里的瓶颈。请参阅我的问题 需要微秒延迟。 NET 应用程序用于限制 UDP 多播传输速率 来解决该问题(在 while 循环中使用Stopwatch 来实现微秒级的延迟)。

Try making your socket's send or receive buffer (server or client) large enough to accommodate the amount of traffic you expect to deal with. Here is some sample C# code from my own UDP multicast server/client on the server side where dataSock is my Socket bound to the UDP multicast group:

dataSock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, (NumberOfPackets * PacketSize) + SmallEpsilonForExtraHeadroom);

Also be sure and set SocketOptionName.SendBuffer on your client side to match the buffer size your server is producing.

I would also recommend, if you were not already aware, to make your packet sizes less than the MTU. By default, MTUs are set to 1500 bytes. (MTU is maximum transmission unit size)

You may still get dropped packets unless you also throttle your send rate, to make sure your clients can keep up. Your network hardware is most likely not the bottleneck here. See my question Need microsecond delay in .NET app for throttling UDP multicast transmission rate for an answer to that problem (using Stopwatch in a while-loop for delays on the order of microseconds).

半﹌身腐败 2024-08-17 03:29:50

我不是这方面的专家,但这听起来像是您遇到了网络容量的问题。您可能需要升级硬件以获得更好的吞吐量。但如果不知道数据包的大小、网络带宽或有多少台机器正在尝试通信等,这只是一个猜测。

I'm no expert on this, but it sounds like your bumping up against the capacity of your network. You may need to upgrade your hardware to get better throughput. But without knowing the size of the packets, the network bandwidth, or how many machines are trying to communicate, etc., that's just a guess.

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