PacketSize for outgoing INVITE from asterisk does NOT follow the incoming INVITE

Hi
I’m using Asterisk 19.1.0 pjSip.
I have 2 phones using the asterisk PBX.
Phone 1 need to call phone 2.

Phone 1 send INVITE to asterisk, with the following RTP setting:

v=0
o=12345451 1755437845 1755437845 IN IP4 192.168.10.230
s=-
c=IN IP4 192.168.10.230
t=0 0
m=audio 16398 RTP/AVP 0 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:9 G722/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:40
a=maxptime:80
a=sendrecv
a=rtcp:16399

But asterisk sends the following to phone 2:

v=0
o=- 332319616 332319616 IN IP4 192.168.10.234
s=Asterisk
c=IN IP4 192.168.10.234
t=0 0
m=audio 17754 RTP/AVP 0 9 18 4 111 8 107 101
a=rtpmap:0 PCMU/8000
a=rtpmap:9 G722/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:4 G723/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:107 opus/48000/2
a=fmtp:107 useinbandfec=1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:20
a=sendrecv

where the ptime is set to 20ms

asterisk accepts phone 1 packet size of 40ms. So between phone 1 and asterisk the packetsize is 40ms, but between asterisk and phone2 the packet size is 20ms.

I would like that the packetsize between asterisk and phone 2 is also 40ms (following the initial request from phone1)

I call from extension 12345451 (phone1) to 12345452 (phone2) and use the following config file:

[general]
tlsenable=yes
tlsdontverifyserver=yes ;no
;tlscertfile=/etc/asterisk/keys/asterisk.pem
tlscertfile=/etc/asterisk/keys/default.pem
transport=udp

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

endpoint-basic
type=endpoint
context=from-internal
disallow=all
allow=g729
allow=g723
allow=ulaw
allow=g722
allow=g726
allow=alaw
allow=opus
direct_media=no

26596000
auth=26596000
aors=26596000

[26596000]
type=auth
auth_type=userpass
password=26596000
username=26596000

[26596000]
type=aor
max_contacts=10

;Extensions start here 12345451
[12345451]
type=endpoint
context=from-internal
disallow=all
allow=g729
allow=g723
allow=ulaw
allow=g722
allow=g726
allow=alaw
allow=opus
direct_media=no
use_ptime=yes
auth=12345451
aors=12345451

[12345451]
type=auth
auth_type=userpass
password=pswd12345451
username=12345451

[12345451]
type=aor
max_contacts=1
remove_existing=true

;Extensions start here 12345452
[12345452]
type=endpoint
context=from-internal
disallow=all
allow=g729
allow=g723
allow=ulaw
allow=g722
allow=g726
allow=alaw
allow=opus
direct_media=no
use_ptime=yes
auth=12345452
aors=12345452

[12345452]
type=auth
auth_type=userpass
password=pswd12345452
username=12345452

[12345452]
type=aor
max_contacts=1
remove_existing=true

;Extensions start here 12345453
[12345453]
type=endpoint
context=from-internal
disallow=all
allow=g729
allow=g723
allow=ulaw
allow=g722
allow=g726
allow=alaw
allow=opus
direct_media=no
use_ptime=yes
auth=12345453
aors=12345453

extensions.conf it setup as below:

[from-internal]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()

exten=>_12345XXX,1,Dial(PJSIP/${EXTEN},50)

Hi Again
I found out that the problem is the ptime can’t be picked up from the incoming call:
WARNING[2754710]: pjsip/dialplan_functions.c:843 channel_read_pjsip: Unrecognized argument ‘media’ for ‘pjsip’ information
[Jan 22 09:29:45] WARNING[2754837][C-00000001]: func_channel.c:477 func_channel_read: Unknown or unavailable item requested: ‘pjsip,media,0,audio,ptime’
– Executing [12345452@from-internal:2] Set(“PJSIP/12345451-00000000”, “INBOUND_PTIME=”) in new stack
– Executing [12345452@from-internal:3] NoOp(“PJSIP/12345451-00000000”, "Captured inbound ptime: ") in new stack
– Executing [12345452@from-internal:4] Dial(“PJSIP/12345451-00000000”, “PJSIP/12345452,50,PJSIP_HEADER(add,ptime:)”) in new stack
– Called PJSIP/12345452

below is the INVITE from my phone, can anybody see what is wrong with the INVITE:

Content-Type: application/sdp
Content-Length: 254

v=0
o=12345452 1933677736 1933677736 IN IP4 192.168.10.245
s=-
c=IN IP4 192.168.10.245
t=0 0
m=audio 16420 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:40
a=maxptime:80
a=sendrecv
a=rtcp:16421

I do not believe ptime is passed through, if you wanted to specify it on the outgoing side I think you can specify it as part of the “allow” line such as “allow=ulaw:40”.

Additionally

This doesn’t exist/work.

And ptime is not a SIP header. It’s part of SDP, which you can’t manipulate in dialplan.

Hi Jcolp
Thanks you for your answer.
I have tried to set allow=ulaw:40, but 20ms is still used.
Have I setup something wrong in my extensions.conf file:

[from-internal]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()

exten=>_12345XXX,1,Dial(PJSIP/${EXTEN},50)

(I’m not very familiar with changing this file )

Br Bo

No, you haven’t. The “ptime” support is old and in practice few people care about it, so knowledge about it/etc doesn’t really exist very much. I don’t recall anything further.