1

I am trying the multicast sample of boost::asio document to receive UDP packets. When the packets coming are around 40,000 packet/second, it is fine. If the packets are 100,000 packet/second, I get packets dropped.

I log the time when every time the callback(handle_receive_from) is called. It usually takes 1 microsecond to receive a packet, but every 32 packets, I got a big delay. For example, from packet 1 to 30, it takes 1 microsecond each, but packet No. 31, it takes about 500+ microsecond, and 32 will be like 20.

I check my CPU usage, only one core is used, and it is 100%. I tried to use multiple threads using one io service, it doesn't change anything.

Can Asio handle traffic more than 100,000 packets/second? How can I achieve it?

Thank you very much in advance.

Jenny
  • 11
  • 2
  • Do you know whether your network sustains that load? Does your OS support it (can you achieve it using other programs?). The bursty delays is something observed more often on SO, but also rule out observer error: https://stackoverflow.com/a/35676305/85371 – sehe Nov 01 '17 at 00:00
  • 1
    You'll need to replace the allocator which ASIO uses with a custom one, and also look into replacing the mutex around the core dispatcher (depending on platform). But ultimately ASIO is a design from the mid-2000s, if on Windows then you really want to use Registered I/O (RIO) with a supporting NIC, then you'll truly see some UDP throughput per CPU core. On Linux user-space networking is usually the way forwards. Good luck! – Niall Douglas Nov 01 '17 at 01:41
  • Thank you sehe! My network sustains the load. If I use Wireshark, I get all the packets. In the case of 40,000 packets/second, I also see the burst of delay, but I actually get all the packets when using asio. Do you mean the burst is normal? – Jenny Nov 01 '17 at 12:46
  • Thank you Niall. When you say replace the allocator, do you mean use MutableBufferSequence? I tried it, and I also tried to use circular buffers, none of them helped. How do I replace mutex around the core dispatcher? I am on Windows. In the case of 40,000 packets/seconds, the CPU usage is only in one core as well, but it is around 50%. Probably the CPU is the issue. How to use RIO? I am going to do some research. – Jenny Nov 01 '17 at 12:56

0 Answers0