PJSIP extension no DSCP (46 or ef or 0xb8) set by default

My provider called me to say that my rtp packages aren’t marked correctly for QoS. They use TOS (type of service) 46 (or ef or 0xb8) to prioritize the rtp stream.

I grabed some packages with tcpdump and really there isn’t. I have seen that FreePBX mark same rtp with old chan_sip by default but not with chan_pjsip. I found a tip in this forum (QoS / ToS / DSCP not configurable and defaulting to no priority with PJSIP) to add an entry ‘tos_audio=ef’ in file ‘pjsip_endpoint_custom_post.conf’. This is an uncomfortable solution for the trunk.

Then I checked that all packages from my internal devices to FreePBX server are marked also, but no one from server to the device.

Itsn’t it possible to mark rtp packages via pjsip by default by adding the line ‘tos_audio=ef’ in ‘pjsip_endpoint.conf’ in each extension.

Thank you.

You can set the tos (and cos) at the transport level by editing the file /etc/asterisk/pjsip.transports_custom_post.conf and adding the lines:

[0.0.0.0-udp](+)
tos=0xB8
cos=184

Then reload with fwconsole r and confirm the setting with:

[root@lgaetzdev2 ~]# asterisk -x “pjsip show transports”

Transport:  <TransportId........>  <Type>  <cos>  <tos>  <BindAddress....................>
==========================================================================================

Transport:  0.0.0.0-tcp               tcp      0      0  0.0.0.0:5160
Transport:  0.0.0.0-tls               tls      0      0  0.0.0.0:5161
Transport:  0.0.0.0-udp               udp    184    184  0.0.0.0:5160

You can do the same with TCP and TLS if necessary by adding sections:

[0.0.0.0-tls](+)
tos=0xB8
cos=184

[0.0.0.0-tcp](+)
tos=0xB8
cos=184

Thank you for your answer. That’s the half way only. I entered your proposed transport tos and cos values. PJSIP shows 184 on both also.

BUT this is SIP signaling and not the audio stream package of RTP. My UDP (and TLS) packages with SIP have a DSCP value “ef” now (checked with tcpdump). The RTP package from FreePBX to client device have still value ‘cs0’.

I think this is settable in section “endpoint” per extension only with “tos_audio=ef”.

1 Like

I have the same question ! How can we set that globally ???

Unlike chan_sip, no way to set pjsip tos_audio globally AFAIK, which is a nuisance.
It must be set for each individual endpoint and updated each time one adds/removes/renames an endpoint.
Here’s a sample entry for pjsip.endpoint_custom_post.conf:

[Telnyx_005](+)
tos_audio=ef

1 Like

I have almost 400 extensions on this PBX, can you imagine the work?

I added a rule in iptables that all RTP traffic must be tagged with DSCP 46, it seems to work fine.
I just hope FreePBX won’t overwrite the config file …

It’s not that bad. In pjsip-speak an endpoint is either an extension or a trunk. You can ignore extensions and set tos_audio on trunks. But you seem to have solved the problem already with iptables.

I have never used the FreePBX firewall. If you do use it, I don’t know if it will mess with your manual changes to iptables.

[ EDIT ]

One other note: Once your packets hit the public Internet no one pays any attention to your QoS. Your QoS is solely for the benefit of your own router.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.