[vlc-devel] [PATCH 3/3] access/udp: reduce mtu amount on initial packets
Ilkka Ollakka
ileoo at videolan.org
Tue Oct 16 11:58:52 CEST 2018
On Mon, Oct 15, 2018 at 09:30:53PM +0300, Ilkka Ollakka wrote:
> In this approach, mtu is setted to high on start, and if received data
> is less than 1500 and mtu is higher than that, we adjust mtu on future
> packets to be smaller. In majority of cases in UDP streaming, packet
> size is usually quite constant, so it should work, even if it's not
> generic solution to udp packet receiving.
>
> Also in case of truncing packets on other than linux systems, use same
> assumption and peek the next data amount to adjust mtu for future
> packets. We don't call PEEK on all the cases, as it would be unnecessary
> system call on majority of the calls.
>
> ref #20952 and other similar tickets.
> ---
> modules/access/udp.c | 40 +++++++++++++++++++++++++++++++++++++---
> 1 file changed, 37 insertions(+), 3 deletions(-)
> +#ifdef __linux__
> msg_Err(access, "%zd bytes packet truncated (MTU was %zu)",
> len, sys->mtu);
> - pkt->i_flags |= BLOCK_FLAG_CORRUPTED;
> sys->mtu = len;
> +#else
> + sys->mtu = recv(sys->fd, pkt->p_buffer, sys->mtu, MSG_PEEK|MSG_TRUNC);
This ofcourse requires separated temporary buffer/size, so we don't overwrite already
received and corrupted packet. But I'll fix that if the approach seems valid.
> + /* In this case, len is old mtu and max received amount, mtu is the
> + * peeked value, that's why they are otherway around in this compared
> + * to __linux__ case error
> + */
> + msg_Err(access, "%zd bytes packet truncated (MTU was %zu)",
> + sys->mtu, len);
> +#endif
> }
> else
> +#endif
> pkt->i_buffer = len;
>
> return pkt;
> --
> 2.19.0
>
--
Ilkka Ollakka
More information about the vlc-devel
mailing list