Commit 2242f971 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Allow all RTT parameters to be configured

Note that this commit effectively disables the computation of a cost
from the RTT, since 'max-rtt-penalty' defaults to 0.
parent 4b5b319f
...@@ -329,6 +329,35 @@ This defines the interval between full routing table dumps sent on this ...@@ -329,6 +329,35 @@ This defines the interval between full routing table dumps sent on this
interface; since Babel uses triggered updates and doesn't count to interface; since Babel uses triggered updates and doesn't count to
infinity, this can be set to a fairly large value, unless significant infinity, this can be set to a fairly large value, unless significant
packet loss is expected. The default is four times the hello interval. packet loss is expected. The default is four times the hello interval.
.TP
.BI rtt\-exponential\-decay " decay"
This specifies the decay factor for the exponential moving average of
RTT samples, in units of 1/256. Must be between 1 and 256, inclusive.
Higher values discard old samples faster. The default is
.BR 42 .
.TP
.BI rtt\-min " rtt"
This specifies the minimum RTT, in milliseconds, starting from which
we increase the cost to a neighbour. The additional cost is linear in
(rtt -
.BR rtt\-min ).
The default is
.B 10
ms.
.TP
.BI rtt\-max " rtt"
This specifies the maximum RTT, in milliseconds, above which we don't
increase the cost to a neighbour. The default is
.B 120
ms.
.TP
.BI max\-rtt\-penalty " cost"
This specifies the maximum cost added to a neighbour because of RTT,
i.e. when the RTT is higher or equal than
.BR rtt\-max .
The default is
.BR 0 ,
which effectively disables the use of a RTT-based cost.
.SS Filtering rules .SS Filtering rules
A filtering rule is defined by a single line with the following format: A filtering rule is defined by a single line with the following format:
.IP .IP
......
...@@ -464,6 +464,30 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure, ...@@ -464,6 +464,30 @@ parse_anonymous_ifconf(int c, gnc_t gnc, void *closure,
if((if_conf->channel < 1 || if_conf->channel > 255) && if((if_conf->channel < 1 || if_conf->channel > 255) &&
if_conf->channel != IF_CHANNEL_NONINTERFERING) if_conf->channel != IF_CHANNEL_NONINTERFERING)
goto error; goto error;
} else if(strcmp(token, "rtt-exponential-decay") == 0) {
int decay;
c = getint(c, &decay, gnc, closure);
if(c < -1 || decay <= 0 || decay > 256)
goto error;
if_conf->rtt_exponential_decay = decay;
} else if(strcmp(token, "rtt-min") == 0) {
int rtt;
c = getthousands(c, &rtt, gnc, closure);
if(c < -1 || rtt <= 0)
goto error;
if_conf->rtt_min = rtt;
} else if(strcmp(token, "rtt-max") == 0) {
int rtt;
c = getthousands(c, &rtt, gnc, closure);
if(c < -1 || rtt <= 0)
goto error;
if_conf->rtt_max = rtt;
} else if(strcmp(token, "max-rtt-penalty") == 0) {
int cost;
c = getint(c, &cost, gnc, closure);
if(c < -1 || cost <= 0 || cost > 0xFFFF)
goto error;
if_conf->max_rtt_penalty = cost;
} else { } else {
goto error; goto error;
} }
...@@ -544,6 +568,10 @@ merge_ifconf(struct interface_conf *dest, ...@@ -544,6 +568,10 @@ merge_ifconf(struct interface_conf *dest,
MERGE(lq); MERGE(lq);
MERGE(faraway); MERGE(faraway);
MERGE(channel); MERGE(channel);
MERGE(rtt_exponential_decay);
MERGE(rtt_min);
MERGE(rtt_max);
MERGE(max_rtt_penalty);
#undef MERGE #undef MERGE
} }
......
...@@ -79,9 +79,6 @@ add_interface(char *ifname, struct interface_conf *if_conf) ...@@ -79,9 +79,6 @@ add_interface(char *ifname, struct interface_conf *if_conf)
ifp->bucket_time = now.tv_sec; ifp->bucket_time = now.tv_sec;
ifp->bucket = BUCKET_TOKENS_MAX; ifp->bucket = BUCKET_TOKENS_MAX;
ifp->hello_seqno = (random() & 0xFFFF); ifp->hello_seqno = (random() & 0xFFFF);
ifp->rtt_min = 10000;
ifp->rtt_max = 120000;
ifp->max_rtt_penalty = 150;
if(interfaces == NULL) if(interfaces == NULL)
interfaces = ifp; interfaces = ifp;
...@@ -308,6 +305,25 @@ interface_up(struct interface *ifp, int up) ...@@ -308,6 +305,25 @@ interface_up(struct interface *ifp, int up)
IF_CONF(ifp, update_interval) : IF_CONF(ifp, update_interval) :
ifp->hello_interval * 4; ifp->hello_interval * 4;
ifp->rtt_exponential_decay =
IF_CONF(ifp, rtt_exponential_decay) > 0 ?
IF_CONF(ifp, rtt_exponential_decay) : 42;
ifp->rtt_min =
IF_CONF(ifp, rtt_min) > 0 ?
IF_CONF(ifp, rtt_min) : 10000;
ifp->rtt_max =
IF_CONF(ifp, rtt_max) > 0 ?
IF_CONF(ifp, rtt_max) : 120000;
if(ifp->rtt_max <= ifp->rtt_min) {
fprintf(stderr,
"Uh, rtt-max is less than or equal to rtt-min (%d <= %d). "
"Setting it to %d.\n", ifp->rtt_max, ifp->rtt_min,
ifp->rtt_min + 10000);
ifp->rtt_max = ifp->rtt_min + 10000;
}
ifp->max_rtt_penalty = IF_CONF(ifp, max_rtt_penalty);
if(ifp->ll) if(ifp->ll)
free(ifp->ll); free(ifp->ll);
ifp->numll = 0; ifp->numll = 0;
......
...@@ -37,6 +37,10 @@ struct interface_conf { ...@@ -37,6 +37,10 @@ struct interface_conf {
char lq; char lq;
char faraway; char faraway;
int channel; int channel;
unsigned int rtt_exponential_decay;
unsigned int rtt_min;
unsigned int rtt_max;
unsigned int max_rtt_penalty;
struct interface_conf *next; struct interface_conf *next;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment