Wrong packetization when Asterisk initiate the call


#1

Hello,

I’m working with the latest Asterisk version (14.6.1). There is an issue with SIP packetization : if Asterisk initiate the call (e.g. by the manager or when receiving an call from chan_mobile) to a SIP user, even if the ptime is right in the SIP/SDP invite frame (i.e. 20ms) the packetization of the RTP flow from Asterisk to the SIP user is 3 or 4ms.
If the call is putted on hold and resumed the packetization is fine !

I noticed it because some of my SIP phone doesn’t support such packetization values and so doesn’t play the flow received by Asterisk.

I used Wireshark to see this issue. The codec is alaw.
Good RTP packet length is 214 (from SIP to Asterisk). Bad RTP packet is 78 (from Asterisk to SIP).

Does someone have an idea ?

Best regards,
Jonathan


#2

Packetisation of outgoing RTP is specified by the remote party.


#3

Hello David,

In my case there is no SIP remote party.

it’s like this :

chan_mobile <-> asterisk Box <-> SIP phone

so the incoming call coming through chan_mobile and is received by Asterisk. Then Asterisk initiate the call to the SIP phone. And the 2 channels are bridged.

In the SIP/SDP invite frame from Asterisk send to the SIP phone, the ptime is 20 but actually the RTP flow send by Asterisk isn’t packetized at 20ms but something between 3 or 4 ms :confused: Notice that the RTP flow from the SIP phone is packetized at 20ms.

The same issue occurs if the call is initiated by the manager (originate action).

Best regards,
Jonathan


#4

The remote party is the SIP phone.


#5

As I said the RTP flow send by the SIP phone is in the right packetization. Furthermore, the packetization is defined by the peer only if the parameter autoframing is set to yes (which is not my case).

The fact is that the SIP trace are right (ptime is defined to 20 by Asterisk) but Asterisk anyway send RTP frames every 3-4 ms instead of every 20ms as it should do due to the SIP/SDP invite frame :confused:


#6

With SDP, each side says what it wants to receive, so the default behaviour would be that the peer send large frames, because Asterisk told it to do so, and Asterisk sends standard frames, because the peer hasn’t told it it is safe to do anything else.


#7

I don’t think that 3ms packet is a standard frame.

Below, there are the frames catpure.

Asterisk box is 192.168.101.27
SIP Phone is 192.168.101.30

The capture was made with an other version of Asterisk. But with Asterisk 14.6.1 the issue is the same.

For information some RTP packets from Asterisk to SIP phone have been deleted (due to forum limitations). […] means that packets have been deleted.

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:52.447218        151 18.053112      192.168.101.27        192.168.101.30        SIP/SDP  858    Request: INVITE sip:sip10@192.168.101.30:5060 | 

Frame 151: 858 bytes on wire (6864 bits), 858 bytes captured (6864 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 5060, Dst Port: 5060
Session Initiation Protocol (INVITE)
    Request-Line: INVITE sip:sip10@192.168.101.30:5060 SIP/2.0
    Message Header
    Message Body
        Session Description Protocol
            Session Description Protocol Version (v): 0
            Owner/Creator, Session Id (o): root 1453928015 1453928015 IN IP4 192.168.101.27
            Session Name (s): Asterisk PBX GIT-14-5d6e90c94a
            Connection Information (c): IN IP4 192.168.101.27
            Time Description, active time (t): 0 0
            Media Description, name and address (m): audio 15296 RTP/AVP 8
            Media Attribute (a): rtpmap:8 PCMA/8000
            Media Attribute (a): ptime:20
            Media Attribute (a): maxptime:150
            Media Attribute (a): sendrecv

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:52.465159        152 18.071053      192.168.101.30        192.168.101.27        SIP      367    Status: 100 Trying | 

Frame 152: 367 bytes on wire (2936 bits), 367 bytes captured (2936 bits)
Ethernet II, Src: XiamenYe_c8:42:ba (00:15:65:c8:42:ba), Dst: Raspberr_cc:85:13 (b8:27:eb:cc:85:13)
Internet Protocol Version 4, Src: 192.168.101.30, Dst: 192.168.101.27
User Datagram Protocol, Src Port: 5060, Dst Port: 5060
Session Initiation Protocol (100)
    Status-Line: SIP/2.0 100 Trying
    Message Header

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:52.572955        153 18.178849      192.168.101.30        192.168.101.27        SIP      595    Status: 180 Ringing | 

Frame 153: 595 bytes on wire (4760 bits), 595 bytes captured (4760 bits)
Ethernet II, Src: XiamenYe_c8:42:ba (00:15:65:c8:42:ba), Dst: Raspberr_cc:85:13 (b8:27:eb:cc:85:13)
Internet Protocol Version 4, Src: 192.168.101.30, Dst: 192.168.101.27
User Datagram Protocol, Src Port: 5060, Dst Port: 5060
Session Initiation Protocol (180)
    Status-Line: SIP/2.0 180 Ringing
    Message Header

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.575807        163 19.181701      192.168.101.30        192.168.101.27        SIP/SDP  782    Status: 200 OK | 

Frame 163: 782 bytes on wire (6256 bits), 782 bytes captured (6256 bits)
Ethernet II, Src: XiamenYe_c8:42:ba (00:15:65:c8:42:ba), Dst: Raspberr_cc:85:13 (b8:27:eb:cc:85:13)
Internet Protocol Version 4, Src: 192.168.101.30, Dst: 192.168.101.27
User Datagram Protocol, Src Port: 5060, Dst Port: 5060
Session Initiation Protocol (200)
    Status-Line: SIP/2.0 200 OK
    Message Header
    Message Body
        Session Description Protocol
            Session Description Protocol Version (v): 0
            Owner/Creator, Session Id (o): - 20002 20002 IN IP4 192.168.101.30
            Session Name (s): SDP data
            Connection Information (c): IN IP4 192.168.101.30
            Time Description, active time (t): 0 0
            Media Description, name and address (m): audio 12128 RTP/AVP 8
            Media Attribute (a): rtpmap:8 PCMA/8000
            Media Attribute (a): ptime:20
            Media Attribute (a): sendrecv

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.578665        164 19.184559      192.168.101.27        192.168.101.30        SIP      467    Request: ACK sip:sip10@192.168.101.30:5060 | 

Frame 164: 467 bytes on wire (3736 bits), 467 bytes captured (3736 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 5060, Dst Port: 5060
Session Initiation Protocol (ACK)
    Request-Line: ACK sip:sip10@192.168.101.30:5060 SIP/2.0
    Message Header

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.585658        165 19.191552      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7751, Time=24

Frame 165: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.586550        169 19.192444      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7753, Time=72

Frame 169: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.595348        171 19.201242      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7754, Time=96

Frame 171: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol
[...]

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.726020        222 19.331914      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7800, Time=1200

Frame 222: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.730390        223 19.336284      192.168.101.30        192.168.101.27        RTP      214    PT=ITU-T G.711 PCMA, SSRC=0xCFF83218, Seq=0, Time=3285617827, Mark

Frame 223: 214 bytes on wire (1712 bits), 214 bytes captured (1712 bits)
Ethernet II, Src: XiamenYe_c8:42:ba (00:15:65:c8:42:ba), Dst: Raspberr_cc:85:13 (b8:27:eb:cc:85:13)
Internet Protocol Version 4, Src: 192.168.101.30, Dst: 192.168.101.27
User Datagram Protocol, Src Port: 12128, Dst Port: 15296
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.735250        224 19.341144      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7801, Time=1224

Frame 224: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.735715        225 19.341609      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7802, Time=1248

Frame 225: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.735916        226 19.341810      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7803, Time=1272

Frame 226: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.745613        227 19.351507      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7804, Time=1296

Frame 227: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.747939        228 19.353833      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7805, Time=1320

Frame 228: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.748281        229 19.354175      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7806, Time=1344

Frame 229: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.750114        230 19.356008      192.168.101.30        192.168.101.27        RTP      214    PT=ITU-T G.711 PCMA, SSRC=0xCFF83218, Seq=1, Time=3285617987

Frame 230: 214 bytes on wire (1712 bits), 214 bytes captured (1712 bits)
Ethernet II, Src: XiamenYe_c8:42:ba (00:15:65:c8:42:ba), Dst: Raspberr_cc:85:13 (b8:27:eb:cc:85:13)
Internet Protocol Version 4, Src: 192.168.101.30, Dst: 192.168.101.27
User Datagram Protocol, Src Port: 12128, Dst Port: 15296
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.755245        231 19.361139      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7807, Time=1368

Frame 231: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.755652        232 19.361546      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7808, Time=1392

Frame 232: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol
[...]

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.765937        237 19.371831      192.168.101.27        192.168.101.30        RTP      78     PT=ITU-T G.711 PCMA, SSRC=0x41EAD40D, Seq=7813, Time=1512

Frame 237: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: Raspberr_cc:85:13 (b8:27:eb:cc:85:13), Dst: XiamenYe_c8:42:ba (00:15:65:c8:42:ba)
Internet Protocol Version 4, Src: 192.168.101.27, Dst: 192.168.101.30
User Datagram Protocol, Src Port: 15296, Dst Port: 12128
Real-Time Transport Protocol

date                          No.     Time           Source                Destination           Protocol Length Info
2017-08-24 05:22:53.770064        238 19.375958      192.168.101.30        192.168.101.27        RTP      214    PT=ITU-T G.711 PCMA, SSRC=0xCFF83218, Seq=2, Time=3285618147

Frame 238: 214 bytes on wire (1712 bits), 214 bytes captured (1712 bits)
Ethernet II, Src: XiamenYe_c8:42:ba (00:15:65:c8:42:ba), Dst: Raspberr_cc:85:13 (b8:27:eb:cc:85:13)
Internet Protocol Version 4, Src: 192.168.101.30, Dst: 192.168.101.27
User Datagram Protocol, Src Port: 12128, Dst Port: 15296
Real-Time Transport Protocol

Does someone know how to solve the issue ?

Best regards,
Jonathan


#8

The best solution is to replace the non-compliant phones. RFC 4566 says ptime is only a recommendation, and, in any case, devices need to cope with shorter frames when changing sources, interposing RFC 2833 signalling, initiating a hold, and on the last frame of a call.

I don’t know why the hold results in the change in behaviour, but my best guesses at work rounds would be: use a conference bridge, force transcoding somehow, or use jitter buffers. I don’t know if any of these will work, and I’m not sure that Asterisk will actually use a jitter buffer if both sides accept jitter.

I’d have to look at the source code to be sure, but I don’t think that Asterisk will consolidate internal frames to create maximal transmitted frames, so if the source side send short frames, I think I would expect Asterisk to send short frames over RTP.

What are the broken phones, so people can avoid them?