Hi All,

 

Hope you are all well?

 

I am hoping you can help with a bit of syntax I am struggling to get working in the intended way. (We are using Kamailio 5.5.3 and using Kemi/python.)

 

The scenario is in AWS where we have separate Kamailio and RTPengine instances, with a cluster of FreeSWITCH EC2's on private addresses only.

 

In the current setup, all RTP routes via the NAT gateway and back to the private IP of the selected FreeSWITCH (and vice versa). This works in the current config, but I would want this traffic not going via the NAT gateway and use the private address and route internally on the VPC. (These EC'2 have only 1 network interface and that cannot be changed for this work.)

 

So anything between FreeSWITCH and Kamailio/RTPengine uses the private IP's for media, the rest use public IP's.

 

It is good to note that the RTPengine's are the same in each set (3 total RTPengine's), just using the public/private IP's based on set ID.

 

My first aim is to use KSR.permissions.allow_source_address() to check if the source address is from the FreeSWITCH cluster and set the rtpengine setID based on this. I have used this method for different parts of the config and it works.

 

I am failing at this first step it seems, as no matter what I use in the function (below) it defaults and uses the public IP's in SDP. (No matter if I use the same setID in each set)

 

kamailio.cfg snippet:

 

# ----- rtpengine params -----

modparam("rtpengine", "setid_avp", "$avp()")

# Public IP's ID 1:

modparam("rtpengine", "rtpengine_sock", "1 == udp:5.5.5.5:2223 udp:6.6.6.6:2223 udp:7.7.7.7:2223")

# Internal IP's ID 2:

modparam("rtpengine", "rtpengine_sock", "2 == udp:10.0.0.1:2223 udp:10.0.0.2:2223 udp:10.0.0.3:2223")

 

Kemi file snippet:

 

# RTPengine Options for different SetID

    def ksr_route_rtpengine(self, msg):

        if KSR.textops.has_body_type("application/sdp") > 0 :

# Source address is private subnet - use RTPengine set 2 (private IP's)

            if KSR.permissions.allow_source_address(400) == 1:

                KSR.rtpengine.set_rtpengine_set(2)

                KSR.rtpengine.rtpengine_manage(

                    "RTP/AVP replace-session-connection replace-origin port-latching ICE=remove")

            else:

# Source address is NOT private - use RTPengine set 1 (public)

                KSR.rtpengine.set_rtpengine_set(1)

                KSR.rtpengine.rtpengine_manage(

                    "RTP/AVP replace-session-connection replace-origin port-latching ICE=remove")

                KSR.xlog.xlog("L_INFO", "RTPengine handling Block")

        return 1

 

 

Group 400 is the private subnet of the FreeSWITCH clusters we have behind on private addresses and the list contains the subnet of private IP's.

 

Using the above, the Kamailio starts fine and understands/loads each set of RTPengine's and calls work with audio. but regardless of the set number used (even only using set 2 in both) it defaults to public IP's in the SDP. (This is the only place in the config where this function is defined)

 

My SDP from FreeSWITCH egress to Kamailio/RTPengine has private IP's in the SDP.

 

The only thing I do not fully understand is the setid_avp - specifically $avp() block and if this needs to stay empty, or be duplicated with the set ID in each one.

 

Any help would be greatly appreciated in understanding where I am going wrong here.

 

Thanks,

 

John.