Asterisk RTCP Stats

Hi,

I’ve been working on getting call quality statistics for my FreePBX system. Following the tutorial link below, I was able to get it partially working:
https://www.voip-info.org/wiki/view/Asterisk+RTCP

My issue is that I’m able to capture rtcp stats only for unanswered calls. For answered calls, all the values for send/receive packets, packet loss, jitter are all zero on the asterisk log file. Additionally, nothing is passed to the master.csv file.

I’ve appended the lines below on my extensions_custom.conf file:

[macro-hangupcall-custom]
; start of QoS reporting
exten => s,1,NoOp(–QoS stats RTPAUDIOQOS: ${RTPAUDIOQOS})
exten => s,n,NoOp(–QoS stats RTPAUDIOQOSBRIDGED: ${RTPAUDIOQOSBRIDGED})
exten => s,n,NoOp(-- QoS stats RTPAUDIOQOSJITTER: ${RTPAUDIOQOSJITTER})
exten => s,n,NoOp(-- QoS stats RTPAUDIOQOSLOSS: ${RTPAUDIOQOSLOSS})
exten => s,n,NoOp(-- QoS stats RTPAUDIOQOSRTT: ${RTPAUDIOQOSRTT})
exten => s,n,NoOp(-- QoS stats RTPAUDIOQOSJITTERBRIDGED: ${RTPAUDIOQOSJITTERBRIDGED})
exten => s,n,NoOp(-- QoS stats RTPAUDIOQOSLOSSBRIDGED: ${RTPAUDIOQOSLOSSBRIDGED})
exten => s,n,NoOp(-- QoS stats RTPAUDIOQOSRTTBRIDGED: ${RTPAUDIOQOSRTTBRIDGED})
exten => s,n,NoOp(-- BRIDGED packet loss: ${CUT(RTPAUDIOQOSLOSSBRIDGED,;,1):5} lost of ${CUT(RTPAUDIOQOSLOSSBRIDGED,;,2):9} in total --)
; - The jitter we measured ourselves - we might also be interested in the maximum jitter
exten => s,n,Set(JITTER_RX_LOCAL_AVG=${CUT(RTPAUDIOQOSJITTER,;,3):12})
exten => s,n,Set(JITTER_RX_REMOTE_AVG=${CUT(RTPAUDIOQOSJITTERBRIDGED,;,3):12})
exten => s,n,Set(RTT_LOCAL_AVG=${CUT(RTPAUDIOQOSRTT,;,3):7})
exten => s,n,Set(RTT_REMOTE_AVG=${CUT(RTPAUDIOQOSRTTBRIDGED,;,3):7})
exten => s,n,GotoIf($["${HANGUPCAUSE}" != “16”]?continue) ; only store the data if this was a normal call
exten => s,n,Set(LOST_LOCAL_TOT=${MATH(${CUT(RTPAUDIOQOSLOSS,;,1):5} / ${CUT(RTPAUDIOQOSLOSS,;,2):9},float)})
exten => s,n,Set(LOST_REMOTE_TOT=${MATH(${CUT(RTPAUDIOQOSLOSSBRIDGED,;,1):5} / ${CUT(RTPAUDIOQOSLOSSBRIDGED,;,2):9},float)})
exten => s,n,Set(JITTER_REP_LOCAL_AVG=${MATH(${CUT(RTPAUDIOQOSJITTER,;,7):19} / 1000)})
exten => s,n,Set(JITTER_REP_REMOTE_AVG=${MATH(${CUT(RTPAUDIOQOSJITTERBRIDGED,;,7):19} / 1000)})
; Uncomment 4 lines below to update CDRDB
;exten => s,n,Set(CDR(userfield)=${CDR(userfield)}&lost_remote:${LOST_REMOTE_TOT}&lost_local:${LOST_LOCAL_TOT}&format_native=${FORMAT_NATIVE})
;exten => s,n,Set(CDR(userfield)=${CDR(userfield)}&jitter_remote:${JITTER_RX_REMOTE_AVG}&jitter_local:${JITTER_RX_LOCAL_AVG})
;exten => s,n,Set(CDR(userfield)=${CDR(userfield)}&jitter_rep_remote:${JITTER_REP_REMOTE_AVG}&jitter_rep_local:${JITTER_REP_LOCAL_AVG})
;exten => s,n,Set(CDR(userfield)=${CDR(userfield)}&rtt_remote:${RTT_REMOTE_AVG}&rtt_local:${RTT_LOCAL_AVG})
exten => s,n(continue),NoOp(End of QoS)

exten => s,n,MacroExit()

And on extensions_override_freepbx.conf

[macro-hangupcall]
exten => s,1(start),GotoIf($["${USE_CONFIRMATION}"="" | “${RINGGROUP_INDEX}”="" | “${CHANNEL}”!="${UNIQCHAN}"]?theend)
exten => s,n(delrgi),Noop(Deleting: RG/${RINGGROUP_INDEX}/${CHANNEL} ${DB_DELETE(RG/${RINGGROUP_INDEX}/${CHANNEL})})
exten => s,n(theend),ExecIf($["${ONETOUCH_RECFILE}"!="" & “${CDR(recordingfile)}”=""]?Set(CDR(recordingfile)=${ONETOUCH_RECFILE}))
exten => s,n,Macro(hangupcall-custom)
exten => s,n,Hangup
exten => s,n,MacroExit()

What could be wrong with this configuration? Would really appreciate the help.

The handling of CDRs is a bit weird, but the CDR you will get output here is the bridge CDR, whereas you are manipulating the channel CDR.

Thanks @david551 for the response. I’m not sure what you mean exactly. Please clarify. Thanks

Please look at the source code. My understanding of this area is too hazy to give more detail without a detailed look at the source code.

A follow up question on this. With the changes to extensions_custom.conf and extensions_override_freepbx.conf, I’m able to get QoS stats for some scenarios.
For instance, I get some stats if the destination context is “from-trunk”. For unanswered calls, the QoS fields appear but all are empty (no values). And for answered calls, I don’t get any QoS related information i.e. the userfield which is meant to have QoS info is empty.

Is there anyone with experience in doing this? All I need is to capture QoS stats in the CDR log (Master.csv) files for all calls.

Thanks

This is the wrong forum for asking how to hack FreePBX dialplans. You want http://community.freepbx.org/ for that, although I’m not sure you will find the specific expertise there, either, so you may just have to reverse engineer their dialplans.

@david551 At the end of the day, FreePBX is just a GUI for asterisk. So I think the question is still relevant for asterisk users.
I would be keen to know how RTCP QoS stats are handled within Asterisk.

They are made available over the Asterisk manager interface or they can be queried from the dialplan. They aren’t automatically placed into the userfield, the dialplan itself has to do so. I’m unaware of what the FreePBX generated dialplan looks like or the interactions, so I can’t say why it wouldn’t be working.

FreePBX is an application based on Asterisk. It contains a large amount of complex dialplan code that implements several constructs not native to Asterisk, and also severely limits which native Asterisk features can be effectively used.

A simpler way to put it is that it is an asterisk config file generator plus a few other things.

My point was that FreePBX, although it generates asterisk configuration files, is not a general purpose configuration file generator. Firstly a lot of the configuration is not generated by FreePBX, but is supplied as part of it. Of that which is generated, it is generated from templates. The templates are connected together by an abstraction that is far from the underlying Asterisk mechanisms. There are lots of things, e.g. mult-tenant systems, that Asterisk can do, but for which FreePBX is unsuited.

Also this is a zombie thread.