In practical, customer may have different network environment, we will introduce some technologies here that may help you overcome the voice quality issue.
Tos and Cos are just the mark mechanism of the QoS. In the following, we would have brief introduction for them respectively.
The Type of Service (TOS) byte, originally defined in RFC 791, can be set on outgoing IP packets for various protocols, The TOS byte is used by the network to provide some level of Quality of Service (QoS) even if the network is congested with other traffic.
The definition of ToS was changed entirely in RFC 2474, and it is now called Differentiated Service (DS)and the upper 6 bits contain a value called the "DSCP" (Differentiated Services Code Point).
Based on DSCP or IP precedence, traffic can be put into a particular service class. Packets within a service class are treated the same way. So it is the priority of different traffic.
Below is a DSCP to IP Precedence conversion table.
The suggestive value for SIP is CS3 and for Audio is EF.
802.1Q uses 3 bits of the VLAN header as the priority mark. This parameter can take integer values from 0 to 7.
The screen capture below is the ToS and CoS settings on Yeastar S-Series PBX. The deafult values are recommended. But you might try to set it as required.
When a VoIP endpoint sends the RTP packets every 20 milliseconds (ptime=20), in fact the packets do not arrive precisely each 20 milliseconds it means that we cannot just play them out directly when we receive the RTP packets, as it may cause a bad voice quality. So in order to play the voice with a better quality receiver needs to turn the variable delays into constant delays and this can be done by using the Jitter Buffer.
You can try to use Jitter Buffer when having networking issues like packet loss or packets arriving out of order.
In the packet loss case the Jitter Buffer will interpolates the lost frames (maybe the data length is zero) and the codec will handle that packet.
In the out of order case the Jitter Buffer will inserts the packets into the buffer in the right order.
It's important to configure the Jitter Buffer correctly because it will easy cause delay problems. The Adaptive Jitter Buffer is better than the fixed jitter buffer because it will try from the small buffer and it will minimize the delay.
See the Jitter Buffer settings in Yeastar S-Series PBX.
You can enable Jitter Buffer for any trunk or any extension, also you can select to use fixed or adaptive Jitter Buffer.