Boost logo

Boost Users :

Subject: [Boost-users] [asio] udp sendto performance bottleneck
From: Hajo Kirchhoff (mailinglists_at_[hidden])
Date: 2010-10-25 04:25:26


Hi all,
I am porting an application from linux (suse 11) to windows. This
application is sending 75.000 UDP Pakets per second, 1416 bytes each. It
uses sendto. IOW: the application is calling sendto approx 75.000 times
per second. The GBit LAN utilization is in the 80-90% range.

This works fine under linux, but the sendto call under windows takes way
longer than under linux. The overhead is so high that throughput drops
from about 100MB/s to less than 20MB/s.

This seems to be a known problem with the windows sendto call, as cygwin
has a rather complex sendto implementation/emulation and does not suffer
from this problem. They are using WSASendMsg internally and pass
multiple buffers with one system call. WSASendMsg passes an array of
buffers to the networking stack and my impression is that it allows
sending several packets with one system call.

My question: Is it possible to send multiple udp pakets with one
asio::sendto call? asio::sendto accepts multiple buffers but seems to
combine all them into one udp paket. Is there a way to prevent that?

Specifically I want to do the following:

vector<array<char, 1416> > b;
b.push_back(paket1);
b.push_back(paket2);
b.push_back(paket3);
...

m_socket.sendto(b);

This should send three udp pakets with 1416 bytes each instead of one
udp paket with 3*1416 bytes.

How can I do that? Is this possible?

Regards

Hajo

(Sidenote to all people with dropped udp pakets under windows Vista and
7: Have you set the network throttling index to 0xffffffff? Its a
registry key and without it you'll never reach maximum throughput.
Another important aspect is to set the receive buffer count in your
network driver to maximum - usually 512 or more - and to use a good
network card. It _is_ possible to receive close to one Gigabit/sec UDP
pakets if done right. Thanks to asio it is also rather easy :-)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net