The sendmsg() function is used to send data, ancillary data, or a combination of these through a connected or unconnected socket.
The sendmsg() API allows for quality of service (QoS) classification data. QoS policies use this function to define a more granular classification level for outgoing or incoming TCP/IP traffic. They specifically use ancillary data types that apply to the IP layer. The message type used is IP_QOS_CLASSIFICATION_DATA. This ancillary data can be used by the application to define attributes for traffic in a particular TCP connection. If the attributes passed by the application match the attributes defined in the QoS policy, then the TCP traffic is restricted by the policy.
Use the following information to initialize the IP_QOS_CLASSIFICATION_DATA structure:
Connection-level scope indicates that the QoS service level obtained through the classification of this message remains in effect for all subsequent messages that are sent until the next sendmsg() call that has classification data. Message-level scope indicates that the QoS service level assigned only be used for the message data included in this sendmsg() call. Future data sent without QoS classification data inherits the previous connection level QoS assignment (from the last connection-level classification through the sendmsg() API or from the original TCP connection classification during connection establishment).
If the application needs to pass numeric values for the classification data it must first convert them to printable ASCII format. The string specified can be in mixed case and is used in the exact format specified for comparison purposes.
The IP_SET_QOSLEVEL_W_APPL_TOKEN_ASCII does perform slightly better than this option because the application data specified in the policy is saved in ASCII format inside of the TCP/IP stack, thereby eliminating the need to translate the application defined token on every sendmsg() request.
Related concepts
Differentiated service Prioritized classes: How to classify network traffic