[REQUEST] EMI/UCP + throttling: Need beta-testers

"Vincent CHAVANIS" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel,gmane.comp.mobile.kannel.user
Message-ID <1f2d01c67040$2bd476c0$9600a8c0@vince>
Hi,

I need testers to test the throttling patch of EMI/UCP smsc.
You need to configure the throughput option for the SMSC in order to make it work.

Please find in attachement, the patch.
Then apply it to the current CVS sources.

You should now see in your logfiles :
2006-04-07 18:08:24.554 [31695] [42] DEBUG: EMI2[EMI-SMSC]: QOS: Traffic Policy exceeded, we need to sleep <0.198170>sec 
2006-04-07 18:08:24.567 [31695] [42] DEBUG: EMI2[EMI-SMSC]: QOS: Traffic Policy exceeded, we need to sleep <0.185829>sec 
2006-04-07 18:08:24.591 [31695] [42] DEBUG: EMI2[EMI-SMSC]: QOS: Traffic Policy exceeded, we need to sleep <0.161633>sec 

cf (Throttling is not obeyed due to gwthread_wakup of sender thread)
http://bugs.kannel.org/view_bug_page.php?f_id=0000332

Please repport any bugs/comments to this list or/and directly to me.

regards

Vincent

--
Telemaque - NICE - (FR)
Service Technique - Developpement
http://www.telemaque.fr/
[email protected]
Tel : +33 4 93 97 71 64 (fax 68)
0000332-emi_patch_ack.txt (text/plain, 3 KB)
diff -rau /gateway-cvs/gw/smsc/smsc_emi.c /gateway/gw/smsc/smsc_emi.c
--- /gateway-cvs/gw/smsc/smsc_emi.c     2006-04-07 14:54:06.000000000 +0200
+++ /gateway/gw/smsc/smsc_emi.c 2006-04-07 17:12:38.000000000 +0200
@@ -122,6 +122,7 @@
     int         priv_nexttrn;   /* next TRN, this should never be accessed directly.
                                 * use int emi2_next_trn (SMSCConn *conn) instead.
                                 */
+    struct timeval last_mt_microtime;  /* the last microtime a MT was sent over the SMSC */
     time_t     last_activity_time; /* the last time something was sent over the main
                                     * SMSC connection
                                     */
@@ -168,6 +169,9 @@
 
     if (result >= 0 && emimsg->or == 'O' && ( emimsg->ot == 31 || emimsg->ot == 51)) {
        PRIVDATA(conn)->last_activity_time = time (NULL);
+        if (emimsg->ot == 51) {                                    
+            gettimeofday(&PRIVDATA(conn)->last_mt_microtime, 0);
+        }
     }
 
     return result;
@@ -988,9 +990,13 @@
  */
 static int emi2_do_send(SMSCConn *conn, Connection *server)
 {
+    PrivData *privdata = conn->data;
     struct emimsg *emimsg;
+    struct timeval tv;
     Msg *msg;
     double delay = 0;
+    double mt_microtime = 0;
+    double microtime = 0;
 
     if (conn->throughput > 0) {
         delay = 1.0 / conn->throughput;
@@ -1001,8 +1007,32 @@
            (msg = gw_prioqueue_remove(PRIVDATA(conn)->outgoing_queue)) != NULL) {
         int nexttrn = emi2_next_trn(conn);
 
+        gettimeofday(&tv, 0);
+
+        mt_microtime = (double) PRIVDATA(conn)->last_mt_microtime.tv_sec + (double) PRIVDATA(conn)->last_mt_microtime.tv_usec / 1000000;
+        microtime = (double) tv.tv_sec + (double) tv.tv_usec / 1000000;
+
+        debug("smsc.emi2", 0, "EMI2[%s]: QOS: last_mt_microtime:<%f> now:<%f>",
+            octstr_get_cstr(conn->id), mt_microtime, microtime);
+
         if (conn->throughput > 0)
+        {
+            debug("smsc.emi2", 0, "EMI2[%s]: QOS: Sleeping <%f>sec", octstr_get_cstr(conn->id), delay);
             gwthread_sleep(delay);
+            debug("smsc.emi2", 0, "EMI2[%s]: QOS: Sleeping Done.", octstr_get_cstr(conn->id));
+            while (mt_microtime + delay > microtime)
+            {
+                debug("smsc.emi2", 0, "EMI2[%s]: QOS: Traffic Policy exceeded, we need to sleep <%f>sec",
+                    octstr_get_cstr(conn->id), (mt_microtime + delay) - microtime);
+                /* Sleeping rest of time */
+                gwthread_sleep((mt_microtime + delay) - microtime);
+
+                /* Refreshing time */
+                gettimeofday(&tv, 0);
+                mt_microtime = (double) PRIVDATA(conn)->last_mt_microtime.tv_sec + (double) PRIVDATA(conn)->last_mt_microtime.tv_usec / 1000000;
+                microtime = (double) tv.tv_sec + (double) tv.tv_usec / 1000000;
+            }
+        }
 
         /* convert the generic Kannel message into an EMI type message */
         emimsg = msg_to_emimsg(msg, nexttrn, PRIVDATA(conn));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.