QoS DSCP value not set

My sandboxed Mac VoIP application is trying to set a QoS DiffServ DSCP value to mark RTP traffic transmitting voice. It is doing that via a third-party open source library. Specifically, the setsockopt() function is called with the value NET_SERVICE_TYPE_VO in its fourth argument:


status = setsockopt(sock, SOL_SOCKET, SO_NET_SERVICE_TYPE, (void *)&val, sizeof(val));


The function returns success.


However, when I'm tcpdumping this traffic, I see ToS value 0x0. This is happening on macOS 10.14 Mojave. The same binary running on macOS 10.10 produces the expected result: the ToS value provided by tcpdump shows the non-zero value 0xc0.


Am I missing something or should I creae a bug report?

Replies

Have you looked at a Wi-Fi level packet trace of this traffic? My expectation is that your QoS requirement is being reflected there, rather than via DSCP.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Do you have a tip on how to capture and read the Wi-Fi-level traffic on a Mac?


I found a WWDC 2016 video "Networking for the Modern Internet" that says that the Wi-Fi-level QoS marking is supported on all devices but the IP-layer DSCP QoS markings only apply to iOS and only within specific Cisco networks. So I guess that the behavior I see is expected and the reason why the DSCP values are set on the older Yosemite is backwards compatibility.

Do you have a tip on how to capture and read the Wi-Fi-level traffic on a Mac?

Take a look at the Wi-Fi Capture section of QA1176 Getting a Packet Trace (the exact steps have drift a bit since I last updated that Q&A, but the basic strategy still works).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
I have a similar question. I am trying to set up network QoS policy for users running Zoom or Microsoft Teams meetings. Both companies publish information about how their client software will set DSCP values for Audio, Video and Signalling. However, when I run either app and use Wireshark to capture packets from my MacBook, the DSCP values are all set to zero.

Is there something within MacOS that needs to be enabled to trust the DSCP values that applications are setting? I've searched exhaustively and could find nothing.
  • rb

The SO_NET_SERVICE_TYPE option and its siblings StreamNetworkServiceType, NSStreamNetworkServiceType, kCFStreamNetworkServiceType configure Layer 1/2 QoS priority. In case of Wi-Fi they set 802.11 User Priority (UP). Whether it actually gets set in the actually transmitted frame depends on whether the OS trusts your application.

AFAIK for iOS/iPadOS this feature has to be enabled via MDM for a generic app. Apps made by Apple and some other vendors, like Cisco, are trusted without this permissions.

What happens next depends on your network equipment (routers, switches, APs etc) and its configuration. Some may translate received 802.11 UP into DSCP according to some mapping (either via RFC8325 or by whatever policy conceived by network admins).

Additionally, you can set Layer 3 QoS via the DSCP (RFC 2474) field of an IP frame either by setting IP_TOS directly or setting the IP_HDRINCL socket option and supplying custom IP header.

Don't get confused by option's name (TOS): it's exactly the same bits of the IP header. Treat it as DSCP.

See the '-K' and '-z' options in ping.c from Apple opensource for usage examples.