Is it possible to shorten "to-tag" 32 character to 16 character

Hi everyone,

We have two SIP servers in our setup. One is an Asterisk server that we manage, and the other is a custom SIP server developed by another company.

We can successfully initiate calls from the custom SIP server without any issues. However, we are encountering a problem when terminating calls. The issue appears to be related to the To-tag value in SIP signaling.

Asterisk generates a 32-character To-tag and sends it to the custom server. However, the custom server seems to assume that the To-tag is only 16 characters long. As a result, when it sends a request to terminate the call, it includes only the first 16 characters of the To-tag. Because of this mismatch, Asterisk cannot match the dialog and responds with “Call does not exist.”

This behavior suggests that the issue originates from the custom SIP server. However, before escalating it to the vendor, I would like to confirm:

Is it possible to configure Asterisk to generate a shorter (e.g., 16-character) To-tag? If so, how can this be achieved?

Otherwise, we will need to coordinate with the vendor to resolve this incompatibility.

Thanks in advance for your help.

This is the output:

<— Transmitting SIP response (864 bytes) to UDP:192.168.1.21:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.21:5060;rport=5060;received=192.168.1.21;branch=z9hG4bK138199868
Via: SIP/2.0/UDP 192.168.1.41:5060;rport=5060;branch=z9hG4bK1654394224319
Record-Route: sip:192.168.1.21;lr
Call-ID: TestCallID-172.16.61.61-rm86k4132p014
From: “gorev_39” sip:2039@sip.navcom-redzone.com;tag=tpo9n24200014
To: “alm_ans_1” sip:2621@navcom-aa.com;tag=3ae456f0-eec2-4703-8610-212d2f280158
CSeq: 1 INVITE
Server: Asterisk PBX 20.2.1
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Contact: sip:0.0.0.0:5060
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length: 153

v=0
o=- 0 2 IN IP4 0.0.0.0
s=Asterisk
c=IN IP4 0.0.0.0
t=0 0
m=audio 12238 RTP/AVP 8
a=rtpmap:8 PCMA/8000
a=ptime:20
a=maxptime:150
a=inactive

<— Received SIP request (430 bytes) from UDP:192.168.1.21:5060 —>
BYE sip:2621@navcom-aa.com SIP/2.0
v: SIP/2.0/UDP 192.168.1.21:5060;branch=z9hG4bK28452914
v: SIP/2.0/UDP 192.168.1.41:5060;branch=z9hG4bK1654394224319;rport=5060
Max-Forwards: 69
t: alm_ans_1 sip:2621@navcom-aa.com:5060;tag=3ae456f0-eec2-47
f: gorev_39 sip:2039@sip.navcom-redzone.com;tag=tpo9n24200014
Call-ID: TestCallID-172.16.61.61-rm86k4132p014
CSeq: 2 BYE
m: sip:2039@192.168.1.41:5060;transport=udp
l: 0

<— Transmitting SIP response (446 bytes) to UDP:192.168.1.21:5060 —>
SIP/2.0 481 Call/Transaction Does Not Exist
Via: SIP/2.0/UDP 192.168.1.21:5060;received=192.168.1.21;branch=z9hG4bK28452914
Via: SIP/2.0/UDP 192.168.1.41:5060;rport=5060;branch=z9hG4bK1654394224319
Call-ID: TestCallID-172.16.61.61-rm86k4132p014
From: “gorev_39” sip:2039@sip.navcom-redzone.com;tag=tpo9n24200014
To: “alm_ans_1” sip:2621@navcom-aa.com;tag=3ae456f0-eec2-47
CSeq: 2 BYE
Server: Asterisk PBX 20.2.1
Content-Length: 0

unset “caller_name” and use “UUID compliant with RFC 4122“ in “tag”

The upstream SIP server uses “SIP compact headers.”
You can enable it globally:
#sip.conf
[general]
compactheaders = yes

#pjsip.conf
[system]
compact_headers=yes

However, there’s a 99% chance this won’t solve the problem.
The “To” field is limited to 64 bytes on the upstream SIP server.

There is no configuration option. It’s generated by the PJSIP library internally when creating a SIP dialog.

Is there a way to modify the source code so that it generates a 16-byte unique tag instead of a 32-byte one? If so, which part of the source code should be examined to implement this change?

Thanks

Having not looked at this I don’t know specifically where, but it would be in the PJSIP library. Not in Asterisk itself.

Correct. RFC 3261 places no such restriction on the to tag.