Setting DSCP per UDP datagram

503 views
Skip to first unread message

Iñaki Baz Castillo

unread,
Nov 5, 2019, 12:18:16 AM11/5/19
to li...@googlegroups.com
Hi, just wondering how to deal with this scenario in which I need to
set different DSCP values to UDP packets (actually IP packets) sent on
the same uv_udp_t handle.

For instance, I send RTP audio and video packets and need to set a
specific DSCP/ToS value **just** for audio packets:

pseudo-code:
-------------------------------------------------
int tos = 0x60; // CS3 just for audio packets.
uv_os_fd_t fd;

// Get the real file descriptor from our libuv UDP handle:
uv_fileno((const uv_handle_t*)udpHandle, &fd);

// Set ToS/DSCP:
if (setsockopt(sock, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) {
fprintf(stderr,"Error setting TOS: %s\n", strerror(errno));
}

// Try to send the packet synchronously:
uv_udp_try_send(....);

// It fails, so send it asynchronously:
uv_udp_send(....);
--------------------------------------------------

This is: before sending each packet I need to call setsockopt() with
the corresponding DSCP/ToS value for that packet. However, since I may
need to use uv_udp_send() it may happen that, when libuv finally sends
the RTP audio packet, the socket DSCP setting may has been modified
again due to a new call to setsockopt() for a different packet to be
sent.

Just wondering if there is a way to tell libuv "please send this
socket option for sending this data no matter when such a data is
actually sent.

Thanks a lot.


--
Iñaki Baz Castillo
<i...@aliax.net>

Santiago Gimeno

unread,
Nov 6, 2019, 4:51:33 AM11/6/19
to li...@googlegroups.com
Hi Iñaki,

I don't think there is a way right now though I think it might be implemented by extending the uv_udp_send_t structure to hold a "before_send" cb so you can set the option, which in turn could bet unset in the send_cb. (extending the uv_udp_send_t might be possible by using one entry in the reserved field of the uv_req). Of course, this is just an idea which could be bad or simply wrong. I would open an issue in the libuv repo to discuss your use case and possible solutions.

Cheers,

Santi

--
You received this message because you are subscribed to the Google Groups "libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libuv+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/libuv/CALiegfmopAxJ1q-dPnB0zOk%3Dx0q_78U3VVpqZ%2BnDaNq0xoAmrw%40mail.gmail.com.

Iñaki Baz Castillo

unread,
Nov 6, 2019, 4:30:40 PM11/6/19
to li...@googlegroups.com

Iñaki Baz Castillo

unread,
Nov 6, 2019, 4:39:50 PM11/6/19
to li...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages