Skip to content

Examples: RTCPXR

Alexandr Dubovikov edited this page Apr 27, 2019 · 1 revision

HOMER 5

splitter

RTCP-XR PUBLISH Stats

Homer/Kamailio can be used to parse, extract and store custom statistics derived from RTCP-XR PUBLISH reports sent by User-Agents and containing the client side statistics to be made available on a per-call and global basis depending on the case requirements.

Example:

if(is_method("PUBLISH"))
        {

                xlog("PUBLISH");
                if(has_body("application/vq-rtcpxr") && $(rb{s.substr,0,1}) != "x") {
                        xlog("reporting table...");
                        $var(table) = "report_capture";
                        xlog("BODY: $rb");
                        $var(jbn) = 0;$var(nlr) = 0;$var(jdr) = 0;$var(iaj) = 0;$var(mos) = 0;

                        $var(callid) = $(rb{re.subst,/(.*)CallID:([0-9A-Za-z@-]{5,120})(.*)$/\2/s});
                        xlog("CALLID: $var(callid)");
                        $var(localaddress) = $(rb{re.subst,/(.*)LocalAddr:IP=(.*) SSRC(.*)$/\2/s});
                        $var(remoteaddress) = $(rb{re.subst,/(.*)RemoteAddr:IP=(.*) SSRC(.*)$/\2/s});

                        $var(temp) = $(rb{re.subst,/^(.*)JitterBuffer:(.*)JBN=([0-9]{1,5})(.*)$/\3/s});
                        xlog("JITTER: $var(temp)");
                        if(float2int("$var(temp)", 1)) $var(jbn) = $rc;

                        #Packet lost rate
                        $var(temp) = $(rb{re.subst,/^(.*)PacketLoss:(.*)NLR=([0-9.]{1,5})(.*)$/\3/s});
                        if(float2int("$var(temp)", 10)) $var(nlr) = $rc;

                        #Discard rate rate
                        $var(temp) = $(rb{re.subst,/^(.*)PacketLoss:(.*)JDR=([0-9.]{1,5})(.*)$/\3/s});
                        if(float2int("$var(temp)", 10)) $var(jdr) = $rc;

                        #Delay
                        $var(temp) = $(rb{re.subst,/^(.*)Delay:(.*)IAJ=([0-9]{1,5})(.*)$/\3/s});
                        if(float2int("$var(temp)", 1)) $var(iaj) = $rc;

                        #Mos
                        $var(temp) = $(rb{re.subst,/^(.*)QualityEst:(.*)MOSCQ=([0-9.]{1,4})(.*)$/\3/s});
                        if(float2int("$var(temp)", 10)) $var(mos) = $rc;

                        xlog("LocalIP: $var(localaddress)");
                        xlog("RemoteIP: $var(remoteaddress)");
                        xlog("Jitter: $var(jbn)");
                        xlog("Packetlost JDR: $var(jdr)");
                        xlog("Packetlost NLR: $var(nlr)");
                        xlog("MOS: $var(mos)");

                        #if($rU == "destination") $var(customer)="homer";

                        $var(customer)=$fU;

                        statsd_set($var(customer)+"Mos", $var(mos));
                        statsd_set($var(customer)+"NLR", $var(nlr));
                        statsd_set($var(customer)+"JDR", $var(jdr));
                        statsd_set($var(customer)+"JBN", $var(jbn));
                        statsd_set($var(customer)+"IAJ", $var(iaj));

                        report_capture("$var(table)", "$var(callid)");
                        drop;
                }
        }
Clone this wiki locally