How to add PJSIP_HEADER in Bye or the Bye reply

Hi,

my asterisk 14.6 doesn’t sent any latency information or the rtt value in the RTCP stat to my homer server:

{"ssrc":298457265,"type":200,"report_count":1,"sender_information":{"ntp_timestamp_sec":"1510757157","ntp_timestamp_usec":"527611","rtp_timestamp":44536,"packets":279,"octets":44640},"report_blocks":[{"source_ssrc":1175133903,"fraction_lost":0,"packets_lost":0,"highest_seq_no":59510,"ia_jitter":5,"lsr":"0","dlsr":0}]}

I can see the rtt during a call with

CLI> pjsip show channelstats

                                             ...........Receive......... .........Transmit..........
 BridgeId ChannelId ........ UpTime.. Codec.   Count    Lost Pct  Jitter   Count    Lost Pct  Jitter RTT....
 ===========================================================================================================

 7d5a7e23 kamailio-gw-000000 00:00:20 ulaw      488       0    0   0.000    488       0    0   0.000   0.100
 7d5a7e23 kamailio-web-00000 00:00:20 opus      488       0    0   0.000    489       0    0   0.004   0.122

Objects found: 2

so I’m trying to add a custom P-RTP-Stat in the Bye or the Bye reply 200 ok for on the caller’s (incoming) channel in the dialplan but without success:

[macro-stdexten]
...
exten => s,n,Set(CHANNEL(hangup_handler_push)=hdlrxstat,s,1)
...

[hdlrxstat]
exten => s,1,NoOp(-- hangup: add rtcp stat header--)
exten => s,n,NoOp(P-RTP-Stat: PS=${CHANNEL(rtcp,txcount)},PR=${CHANNEL(rtcp,txcount)},PL=${MATH(${CHANNEL(rtcp,remote_normdevrxploss)}*100,int)},JI=${MATH(${CHANNEL(rtcp,remote_normdevjitter)}*1,int)},LA=${MATH(${CHANNEL(rtcp,normdevrtt)}*100,int)},DU=${CDR(billsec)})
exten => s,n,Set(PJSIP_HEADER(add,P-RTP-Stat)=PS=${CHANNEL(rtcp,txcount)},PR=${CHANNEL(rtcp,txcount)},PL=${MATH(${CHANNEL(rtcp,remote_normdevrxploss)}*100,int)},JI=${MATH(${CHANNEL(rtcp*1,remote_normdevjitter)},int)},LA=${MATH(${CHANNEL(rtcp,normdevrtt)}*100,int)},DU=${CDR(billsec)})
exten => s,n,Return()

I just can’t work out what is wrong with this !

Thanks in advance for any help
/Ouss

Neither chan_sip or chan_pjsip currently allow headers to be added to subsequent requests. They can only be added to the initial INVITE.

Thanks for the reply, can I forward this rtt stat or any latency information to homer by the res_hep.so

I’m not familiar with the hep code so I can’t answer that. Someone else may be able to answer.

After your reply I tried to add this header from kamailio with an empty value and update it in the Asterisk but still noting, this header was removed from transaction and I don’t see it in the Bye

[macro-stdexten]
...
exten => s,n,Set(CHANNEL(hangup_handler_push)=hdlrxstat,s,1)
...

[hdlrxstat]
exten => s,1,NoOp(-- hangup rtcp stat --)
exten => s,n,NoOp(X-RTP-Stat: PS=${CHANNEL(rtcp,txcount)},PR=${CHANNEL(rtcp,txcount)},PL=${MATH(${CHANNEL(rtcp,remote_normdevrxploss)}*100,int)},JI=${MATH(${CHANNEL(rtcp,remote_normdevjitter)}*1,int)},LA=${MATH(${CHANNEL(rtcp,normdevrtt)}*100,int)},DU=${CDR(billsec)})
exten => s,n,Set(PJSIP_HEADER(update,X-RTP-Stat)= PS=${CHANNEL(rtcp,txcount)},PR=${CHANNEL(rtcp,txcount)},PL=${MATH(${CHANNEL(rtcp,remote_normdevrxploss)}*100,int)},JI=${MATH(${CHANNEL(rtcp,remote_normdevjitter)}*1,int)},LA=${MATH(${CHANNEL(rtcp,normdevrtt)}*100,int)},DU=${CDR(billsec)} )
exten => s,n,Return()

is that normal ?

Thanks in advance for any help
/Ouss

As I stated headers are not applied to (or retrieved from) anything except the initial INVITE.

1 Like