How to set UDP Socket TOS / DSCP

in Golang it's easy to use SetDSCP sets the 6bit DSCP field in IPv4 header, or 8bit Traffic Class in IPv6 header.

How do I achieve it in Rust UDP Socket?

Thanks

Yeah it doesn't seems there's an easy way for it. Here's a PR on the socket2 crate to add this feature.

Note that setting those flags on application is discouraged as ISPs tends to overwrite them on the network edge. The PR conversation contains a link to the windows document mentioning "DO NOT USE".

They're usable and useful when the connection is exclusively transiting private networks. If such a private network isn't stripping DSCP on ingress & egress, they have a bug that will turn into a deliverability problem :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.