2
0
Эх сурвалжийг харах

Add Bandwidth AVP to Rx-Requests as per 3GPP TS 29.213

Carsten Bock 10 жил өмнө
parent
commit
461aad8cae

+ 15 - 0
modules/ims_qos/doc/ims_qos.xml

@@ -44,6 +44,17 @@
 
         <email>[email protected]</email>
       </author>
+
+      <author>
+        <firstname>Carsten</firstname>
+
+        <surname>Bock</surname>
+        <affiliation>
+          <orgname>ng-voice GmbH</orgname>
+        </affiliation>
+
+        <email>[email protected]</email>
+      </author>
     </authorgroup>
 
     <copyright>
@@ -56,6 +67,10 @@
 
       <holder>Smile Communications</holder>
     </copyright>
+    <copyright>
+      <year>2015</year>
+      <holder>ng-voice GmbH</holder>
+    </copyright>
   </bookinfo>
 
   <toc/>

+ 38 - 0
modules/ims_qos/doc/ims_qos_admin.xml

@@ -216,6 +216,44 @@ modparam("ims_qos", "authorize_video_flow", 0)
         <programlisting format="linespecific">
 ...
 modparam("ims_qos", "cdp_event_list_size_threshold", 10)
+...
+        </programlisting>
+      </example>
+    </section>
+    <section>
+      <title><varname>audio_default_bandwidth</varname> (integer)</title>
+
+      <para>This parameters defines the default bandwidth for Audio,
+            if no "b=AS"-Parameter is found in the SDP.</para>
+
+      <para><emphasis> Default value is 64 (64 kBit)</emphasis></para>
+
+      <example>
+        <title><varname>audio_default_bandwidth</varname> parameter
+        usage</title>
+
+        <programlisting format="linespecific">
+...
+modparam("ims_qos", "audio_default_bandwidth", 32)
+...
+        </programlisting>
+      </example>
+    </section>
+    <section>
+      <title><varname>video_default_bandwidth</varname> (integer)</title>
+
+      <para>This parameters defines the default bandwidth for Video,
+            if no "b=AS"-Parameter is found in the SDP.</para>
+
+      <para><emphasis> Default value is 128 (128 kBit)</emphasis></para>
+
+      <example>
+        <title><varname>video_default_bandwidth</varname> parameter
+        usage</title>
+
+        <programlisting format="linespecific">
+...
+modparam("ims_qos", "video_default_bandwidth", 256)
 ...
         </programlisting>
       </example>

+ 5 - 0
modules/ims_qos/mod.c

@@ -98,6 +98,9 @@ int cdp_event_latency = 1; /*flag: report slow processing of CDP callback events
 int cdp_event_threshold = 500; /*time in ms above which we should report slow processing of CDP callback event - default 500ms*/
 int cdp_event_latency_loglevel = 0; /*log-level to use to report slow processing of CDP callback event - default ERROR*/
 
+int audio_default_bandwidth = 64;
+int video_default_bandwidth = 128;
+
 int cdp_event_list_size_threshold = 0;  /**Threshold for size of cdp event list after which a warning is logged */
 
 /** module functions */
@@ -134,6 +137,8 @@ static param_export_t params[] = {
     { "cdp_event_latency_log", INT_PARAM, &cdp_event_latency_loglevel}, /*log-level to use to report slow processing of CDP callback event*/
     { "authorize_video_flow", INT_PARAM, &authorize_video_flow}, /*whether or not we authorize resources for video flows*/
     { "cdp_event_list_size_threshold", INT_PARAM, &cdp_event_list_size_threshold}, /**Threshold for size of cdp event list after which a warning is logged */
+    { "audio_default_bandwidth", INT_PARAM, &audio_default_bandwidth},
+    { "video_default_bandwidth", INT_PARAM, &video_default_bandwidth},
     { 0, 0, 0}
 };
 

+ 94 - 0
modules/ims_qos/rx_avp.c

@@ -55,6 +55,7 @@
 #include "rx_authdata.h"
 #include "rx_avp.h"
 #include "mod.h"
+#include "../../parser/sdp/sdp_helpr_funcs.h"
 
 #include "../../lib/ims/ims_getters.h"
 
@@ -343,6 +344,31 @@ int rx_add_subscription_id_avp(AAAMessage *msg, str identifier, int identifier_t
             __FUNCTION__);
 }
 
+inline unsigned int sdp_b_value(str * payload, char * subtype) {
+   char * line;
+   unsigned int i;
+   str s;
+   line = find_sdp_line(payload->s, payload->s + payload->len, 'b');
+   while (line != NULL) {
+      // b=AS:
+      if ((line[2] == subtype[0]) && (line[3] == subtype[1])) {
+        LM_DBG("SDP-Line: %.*s\n", 5, line);
+        line += 5;
+        i = 0;
+        while ((line[i] != '\r') && (line[i] != '\n') && ((line +i) <= (payload->s + payload->len))) {
+          i++;
+	}
+        s.s = line;
+        s.len = i;
+        LM_DBG("value: %.*s\n", s.len, s.s);
+        if (str2int(&s, &i) == 0) return i;
+        else return 0;
+      }
+      line = find_next_sdp_line(line, payload->s + payload->len, 'b', NULL);
+   }
+   return 0;
+}
+
 inline int rx_add_media_component_description_avp(AAAMessage *msg, int number, str *media_description, str *ipA, str *portA, str *ipB, str *portB, str *transport,
         str *req_raw_payload, str *rpl_raw_payload, enum dialog_direction dlg_direction) {
     str data;
@@ -351,8 +377,10 @@ inline int rx_add_media_component_description_avp(AAAMessage *msg, int number, s
     AAA_AVP *codec_data1, *codec_data2;
     AAA_AVP * media_sub_component[PCC_Media_Sub_Components];
     AAA_AVP *flow_status;
+    AAA_AVP *dl_bw, *ul_bw, *rs_bw, *rr_bw;
 
     int media_sub_component_number = 0;
+    unsigned int bandwidth = 0;
 
     int type;
     char x[4];
@@ -412,6 +440,72 @@ inline int rx_add_media_component_description_avp(AAAMessage *msg, int number, s
     cdpb.AAAAddAVPToList(&list, media_type);
 
     /*RR and RS*/
+    if ((type == AVP_IMS_Media_Type_Audio) || (type == AVP_IMS_Media_Type_Video)) {
+	// Get bandwidth from SDP:
+        bandwidth = sdp_b_value(req_raw_payload, "AS");
+        LM_DBG("Request: got bandwidth %i from b=AS-Line\n", bandwidth);
+        // Set default values:
+        if ((type == AVP_IMS_Media_Type_Audio) && (bandwidth <= 0))
+	  bandwidth = audio_default_bandwidth;
+        if ((type == AVP_IMS_Media_Type_Video) && (bandwidth <= 0))
+	  bandwidth = video_default_bandwidth;
+        
+        // According to 3GPP TS 29.213, Rel. 9+, this value is * 1000:
+        bandwidth *= 1000; 
+  
+        // Add AVP
+        set_4bytes(x,bandwidth);
+	ul_bw = cdpb.AAACreateAVP(AVP_EPC_Max_Requested_Bandwidth_UL,
+            AAA_AVP_FLAG_MANDATORY | AAA_AVP_FLAG_VENDOR_SPECIFIC,
+            IMS_vendor_id_3GPP, x, 4,
+            AVP_DUPLICATE_DATA);
+    	cdpb.AAAAddAVPToList(&list, ul_bw);
+
+	// Get bandwidth from SDP:
+        bandwidth = sdp_b_value(rpl_raw_payload, "AS");
+        LM_DBG("Answer: got bandwidth %i from b=AS-Line\n", bandwidth);
+        // Set default values:
+        if ((type == AVP_IMS_Media_Type_Audio) && (bandwidth <= 0))
+	  bandwidth = audio_default_bandwidth;
+        if ((type == AVP_IMS_Media_Type_Video) && (bandwidth <= 0))
+	  bandwidth = video_default_bandwidth;
+
+        // According to 3GPP TS 29.213, Rel. 9+, this value is * 1000:
+        bandwidth *= 1000; 
+        
+        // Add AVP
+        set_4bytes(x,bandwidth);
+	dl_bw = cdpb.AAACreateAVP(AVP_EPC_Max_Requested_Bandwidth_DL,
+            AAA_AVP_FLAG_MANDATORY | AAA_AVP_FLAG_VENDOR_SPECIFIC,
+            IMS_vendor_id_3GPP, x, 4,
+            AVP_DUPLICATE_DATA);
+    	cdpb.AAAAddAVPToList(&list, dl_bw);
+
+	// Get A=RS-bandwidth from SDP-Reply:
+        bandwidth = sdp_b_value(rpl_raw_payload, "RS");
+        LM_DBG("Answer: Got bandwidth %i from b=RS-Line\n", bandwidth);
+	if (bandwidth >= 0) {
+		// Add AVP
+		set_4bytes(x,bandwidth);
+		rs_bw = cdpb.AAACreateAVP(AVP_EPC_RS_Bandwidth,
+		    AAA_AVP_FLAG_MANDATORY | AAA_AVP_FLAG_VENDOR_SPECIFIC,
+		    IMS_vendor_id_3GPP, x, 4,
+		    AVP_DUPLICATE_DATA);
+		cdpb.AAAAddAVPToList(&list, rs_bw);
+	}
+	// Get A=RS-bandwidth from SDP-Reply:
+        bandwidth = sdp_b_value(rpl_raw_payload, "RR");
+        LM_DBG("Answer: Got bandwidth %i from b=RR-Line\n", bandwidth);
+	if (bandwidth >= 0) {
+		// Add AVP
+		set_4bytes(x,bandwidth);
+		rr_bw = cdpb.AAACreateAVP(AVP_EPC_RR_Bandwidth,
+		    AAA_AVP_FLAG_MANDATORY | AAA_AVP_FLAG_VENDOR_SPECIFIC,
+		    IMS_vendor_id_3GPP, x, 4,
+		    AVP_DUPLICATE_DATA);
+		cdpb.AAAAddAVPToList(&list, rr_bw);
+	}
+    }
 
     /*codec-data*/
 

+ 4 - 0
modules/ims_qos/rx_avp.h

@@ -64,6 +64,10 @@ struct AAA_AVP_List;
 struct AAAMessage;
 enum dialog_direction;
 
+int audio_default_bandwidth;
+int video_default_bandwidth;
+
+
 /*helper*/
 int rx_add_framed_ip_avp(AAA_AVP_LIST * list, str ip, uint16_t version);