Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP Multicast Performance Under Load

Tags:

c#

udp

multicast

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.

like image 630
Anton Avatar asked Oct 31 '09 00:10

Anton


2 Answers

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).

like image 68
James Dunne Avatar answered Nov 18 '22 16:11

James Dunne


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.

like image 43
Jeffrey L Whitledge Avatar answered Nov 18 '22 15:11

Jeffrey L Whitledge