Changeset 4957


Ignore:
Timestamp:
Nov 4, 2014 8:00:15 AM (10 years ago)
Author:
nanang
Message:

Close #1802: Configurable randomized value range for auto re-registration interval.

Location:
pjproject/trunk/pjsip
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r4955 r4957  
    32933293     * occurs because of transport failure, the first retry will be done 
    32943294     * after \a reg_first_retry_interval seconds instead. Also note that 
    3295      * the interval will be randomized slightly by approximately +/- ten 
    3296      * seconds to avoid all clients re-registering at the same time. 
     3295     * the interval will be randomized slightly by some seconds (specified 
     3296     * in \a reg_retry_random_interval) to avoid all clients re-registering 
     3297     * at the same time. 
    32973298     * 
    32983299     * See also \a reg_first_retry_interval setting. 
     
    33053306     * This specifies the interval for the first registration retry. The 
    33063307     * registration retry is explained in \a reg_retry_interval. Note that 
    3307      * the value here will also be randomized by +/- ten seconds. 
     3308     * the value here will also be randomized by some seconds (specified 
     3309     * in \a reg_retry_random_interval) to avoid all clients re-registering 
     3310     * at the same time. 
    33083311     * 
    33093312     * Default: 0 
    33103313     */ 
    33113314    unsigned         reg_first_retry_interval; 
     3315 
     3316    /** 
     3317     * This specifies maximum randomized value to be added/substracted 
     3318     * to/from the registration retry interval specified in \a 
     3319     * reg_retry_interval and \a reg_first_retry_interval, in second. 
     3320     * This is useful to avoid all clients re-registering at the same time. 
     3321     * For example, if the registration retry interval is set to 100 seconds 
     3322     * and this is set to 10 seconds, the actual registration retry interval 
     3323     * will be in the range of 90 to 110 seconds. 
     3324     * 
     3325     * Default: 10 
     3326     */ 
     3327    unsigned         reg_retry_random_interval; 
    33123328 
    33133329    /** 
  • pjproject/trunk/pjsip/include/pjsua2/account.hpp

    r4939 r4957  
    8282     * occurs because of transport failure, the first retry will be done 
    8383     * after \a firstRetryIntervalSec seconds instead. Also note that 
    84      * the interval will be randomized slightly by approximately +/- ten 
    85      * seconds to avoid all clients re-registering at the same time. 
    86      * 
    87      * See also \a firstRetryIntervalSec setting. 
     84     * the interval will be randomized slightly by some seconds (specified 
     85     * in \a reg_retry_random_interval) to avoid all clients re-registering 
     86     * at the same time. 
     87     * 
     88     * See also \a firstRetryIntervalSec and \a randomRetryIntervalSec 
     89     * settings. 
    8890     * 
    8991     * Default: PJSUA_REG_RETRY_INTERVAL 
     
    9496     * This specifies the interval for the first registration retry. The 
    9597     * registration retry is explained in \a retryIntervalSec. Note that 
    96      * the value here will also be randomized by +/- ten seconds. 
     98     * the value here will also be randomized by some seconds (specified 
     99     * in \a reg_retry_random_interval) to avoid all clients re-registering 
     100     * at the same time. 
     101     * 
     102     * See also \a retryIntervalSec and \a randomRetryIntervalSec settings. 
    97103     * 
    98104     * Default: 0 
    99105     */ 
    100106    unsigned            firstRetryIntervalSec; 
     107 
     108    /** 
     109     * This specifies maximum randomized value to be added/substracted 
     110     * to/from the registration retry interval specified in \a 
     111     * reg_retry_interval and \a reg_first_retry_interval, in second. 
     112     * This is useful to avoid all clients re-registering at the same time. 
     113     * For example, if the registration retry interval is set to 100 seconds 
     114     * and this is set to 10 seconds, the actual registration retry interval 
     115     * will be in the range of 90 to 110 seconds. 
     116     * 
     117     * See also \a retryIntervalSec and \a firstRetryIntervalSec settings. 
     118     * 
     119     * Default: 10 
     120     */ 
     121    unsigned            randomRetryIntervalSec; 
    101122 
    102123    /** 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c

    r4955 r4957  
    12051205    acc->cfg.reg_retry_interval = cfg->reg_retry_interval; 
    12061206    acc->cfg.reg_first_retry_interval = cfg->reg_first_retry_interval; 
     1207    acc->cfg.reg_retry_random_interval = cfg->reg_retry_random_interval;     
    12071208    acc->cfg.drop_calls_on_reg_fail = cfg->drop_calls_on_reg_fail; 
    12081209    acc->cfg.register_on_acc_add = cfg->register_on_acc_add; 
     
    35403541    delay.msec = 0; 
    35413542 
    3542     /* Randomize interval by +/- 10 secs */ 
    3543     if (delay.sec >= 10) { 
    3544         delay.msec = -10000 + (pj_rand() % 20000); 
    3545     } else { 
    3546         delay.sec = 0; 
    3547         delay.msec = (pj_rand() % 10000); 
     3543    /* Randomize interval by +/- reg_retry_random_interval, if configured */ 
     3544    if (acc->cfg.reg_retry_random_interval) { 
     3545        long rand_ms = acc->cfg.reg_retry_random_interval * 1000; 
     3546        if (delay.sec >= (long)acc->cfg.reg_retry_random_interval) { 
     3547            delay.msec = -rand_ms + (pj_rand() % (rand_ms * 2)); 
     3548        } else { 
     3549            delay.sec = 0; 
     3550            delay.msec = (pj_rand() % (delay.sec * 1000 + rand_ms)); 
     3551        } 
    35483552    } 
    35493553    pj_time_val_normalize(&delay); 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r4945 r4957  
    289289    cfg->srtp_optional_dup_offer = pjsua_var.ua_cfg.srtp_optional_dup_offer; 
    290290    cfg->reg_retry_interval = PJSUA_REG_RETRY_INTERVAL; 
     291    cfg->reg_retry_random_interval = 10; 
    291292    cfg->contact_rewrite_method = PJSUA_CONTACT_REWRITE_METHOD; 
    292293    cfg->contact_use_src_port = PJ_TRUE; 
  • pjproject/trunk/pjsip/src/pjsua2/account.cpp

    r4939 r4957  
    3939    NODE_READ_UNSIGNED  (this_node, retryIntervalSec); 
    4040    NODE_READ_UNSIGNED  (this_node, firstRetryIntervalSec); 
     41    NODE_READ_UNSIGNED  (this_node, randomRetryIntervalSec); 
    4142    NODE_READ_UNSIGNED  (this_node, delayBeforeRefreshSec); 
    4243    NODE_READ_BOOL      (this_node, dropCallsOnFail); 
     
    5657    NODE_WRITE_UNSIGNED (this_node, retryIntervalSec); 
    5758    NODE_WRITE_UNSIGNED (this_node, firstRetryIntervalSec); 
     59    NODE_WRITE_UNSIGNED (this_node, randomRetryIntervalSec); 
    5860    NODE_WRITE_UNSIGNED (this_node, delayBeforeRefreshSec); 
    5961    NODE_WRITE_BOOL     (this_node, dropCallsOnFail); 
     
    319321    ret.reg_retry_interval      = regConfig.retryIntervalSec; 
    320322    ret.reg_first_retry_interval= regConfig.firstRetryIntervalSec; 
     323    ret.reg_retry_random_interval= regConfig.randomRetryIntervalSec; 
    321324    ret.reg_delay_before_refresh= regConfig.delayBeforeRefreshSec; 
    322325    ret.drop_calls_on_reg_fail  = regConfig.dropCallsOnFail; 
     
    446449    regConfig.retryIntervalSec  = prm.reg_retry_interval; 
    447450    regConfig.firstRetryIntervalSec = prm.reg_first_retry_interval; 
     451    regConfig.randomRetryIntervalSec = prm.reg_retry_random_interval; 
    448452    regConfig.delayBeforeRefreshSec = prm.reg_delay_before_refresh; 
    449453    regConfig.dropCallsOnFail   = PJ2BOOL(prm.drop_calls_on_reg_fail); 
Note: See TracChangeset for help on using the changeset viewer.