lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200809191614.14763.rdenis@simphalempin.com>
Date:	Fri, 19 Sep 2008 16:14:12 +0300
From:	Rémi Denis-Courmont <rdenis@...phalempin.com>
To:	Hirokazu Takahashi <taka@...inux.co.jp>
Cc:	johaahn@...il.com, netdev@...r.kernel.org
Subject: Re: [PATCH] sendfile() and UDP socket

Le vendredi 19 septembre 2008 15:28:54 Hirokazu Takahashi, vous avez écrit :
> > > UDP is a datagram protocol, so I think applications using UDP should
> > > care about the size of packets they are going to send rather than
> > > expecting that the messages will be split into several packets
> > > automatically. If some of the packets have lost, it will be really hard
> > > for the applications to re-create the same ones to send again.
> >
> > Also, why use UDP for this... If you want stream semantics, why not use
> > TCP or SCTP instead?
>
> I think a lot of VoIP and video streaming services are working on UDP.

VoIP uses lots of small packets, considering the typical packetization times. 
Using send(MSG_MORE) + sendfile would definitely be slower than a single 
sendmsg() in such case, because the per-packet memcpy() will be quite short.

Video streaming typically does send lots of large packets, and might well read 
the data from a mmap-able file. But video streaming protocols such as RTP 
typically try to avoid fragmentation, so large sendfile() won't work.

> > > If you want send a large file over UDP, the typical code will be like:
> > >
> > > while (...) {
> > >         sendmsg(fd, &apl_header, sizeof(apl_header), MSG_MORE);
> > >         offset += sendfile(fd, offset, count);
> > > }
> >
> > Correct me if I am wrong, but... Unless you have a big MTU (as _not_ in
> > 1500 bytes :D), doing an extra syscall might be slower than copying data
> > in a single vectorized sendmsg() syscall.
>
> That's not true.
> Even if the MTU is small, you can send a UDP message whose size can be
> up to 64KB at once. They will be split into several IP packets without
> any copies.

And you will encounter fragmentation, which sucks at high data rates.
As for low rates, you typically would not bother to optimize memcpy. But more 
importantly, you should not assume that the other end is only talking to 
you - it might as well be talking to many different people and not appreciate 
if all of them send lots of fragments.

And lets not get into how poorly fragmentation works through middleboxes...

> And more, copying data will pollute the cache memory much, which cannot
> be ignored if you want send tons of data of files.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ