Evaluate `uv_udp_try_send2` available in libuv >= 1.50.0
Details
- libuv 1.50.0 comes with a new function
uv_udp_try_send2. - https://github.com/libuv/libuv/releases/tag/v1.50.0
- https://github.com/libuv/libuv/pull/4644
Add a version of
uv_udp_try_sendthat can send multiple datagrams.Uses
sendmmsgon platforms that support it (Linux, FreeBSD, macOS), falls back to a regularsendmsgloop elsewhere.
The only use case I find is when sending NACK-ed RTP packets. In that case we may want to send N packets at once to a single socket.
Or when we send RTCP compound packets.
how would compound RTCP which needs to be SRTP-encrypted in a single call work? NACK, FEC and maybe pacing... I hear @ggarber ponders re-pacing ;-)
how would compound RTCP which needs to be SRTP-encrypted in a single call work?
I fail to understand the problem you mean. The RTCP compound packet is not split into N datagrams. It's not that way. When mediasoup needs to generate RTCP compound packets it calculates the total size it would need and instead generates N RTCP compound packets of size less than hardcoded MTU (13XX bytes AFAIR) and then it encrypts each compound packet independently before sending each one. Nothing changes here regarding that.
yeah but how often does the get bigger than the MTU?
yeah but how often does the get bigger than the MTU?
How is that related to using this new UDP api in libuv? Absolutely nothing changes here no matter the total size of data to place in RTCP Compound packets.
PR updating libuv to 1.51.0 is here: https://github.com/versatica/mediasoup/pull/1543
The only use case I find is when sending NACK-ed RTP packets. In that case we may want to send N packets at once to a single socket.
Can you explain that? I don't think that's the use case. AFAIU uv_udp_try_send2(uv_udp_t *handle, unsigned int count, uv_buf_t *bufs[/*count*/], unsigned int nbufs[/*count*/], struct sockaddr *addrs[/*count*/], unsigned int flags) is about being able to send data to different addresses in a single system call.
Anyway AFAIS this cannot help us much. There are little use cases in mediasoup in which we want to send the same UDP datagram to different endpoints from the same mediasoup UDP port:
- In WebRTC we have to encode SRTP differently for each endpoint, so no use case here.
- In plain transports we don't send the same packet to different endpoints from the same local port in mediasoup.
- All ICE traffic is specific for each endpoint.
- DTLS depends on each endpoint due to negotiated encryption, etc.
I'm closing this ticket due to rationale in above comment.