Commit 4b5b319f authored by Baptiste Jonglez's avatar Baptiste Jonglez

Make 'rtt_exponential_decay' relative to an interface

parent 9b2ff477
...@@ -58,10 +58,6 @@ struct timeval now; ...@@ -58,10 +58,6 @@ struct timeval now;
unsigned char myid[8]; unsigned char myid[8];
int debug = 0; int debug = 0;
/* A higher value means we forget old RTT samples faster. Must be
between 1 and 256, inclusive. */
unsigned int rtt_exponential_decay = 42;
int link_detect = 0; int link_detect = 0;
int all_wireless = 0; int all_wireless = 0;
int default_wireless_hello_interval = -1; int default_wireless_hello_interval = -1;
......
...@@ -90,7 +90,6 @@ extern int do_daemonise; ...@@ -90,7 +90,6 @@ extern int do_daemonise;
extern const char *logfile, *pidfile, *state_file; extern const char *logfile, *pidfile, *state_file;
extern int link_detect; extern int link_detect;
extern int all_wireless; extern int all_wireless;
extern unsigned int rtt_exponential_decay;
extern unsigned char myid[8]; extern unsigned char myid[8];
......
...@@ -91,6 +91,9 @@ struct interface { ...@@ -91,6 +91,9 @@ struct interface {
unsigned short hello_seqno; unsigned short hello_seqno;
unsigned hello_interval; unsigned hello_interval;
unsigned update_interval; unsigned update_interval;
/* A higher value means we forget old RTT samples faster. Must be
between 1 and 256, inclusive. */
unsigned int rtt_exponential_decay;
/* Parameters for computing the cost associated to RTT. */ /* Parameters for computing the cost associated to RTT. */
unsigned int rtt_min; unsigned int rtt_min;
unsigned int rtt_max; unsigned int rtt_max;
......
...@@ -611,14 +611,16 @@ parse_packet(const unsigned char *from, struct interface *ifp, ...@@ -611,14 +611,16 @@ parse_packet(const unsigned char *from, struct interface *ifp,
debugf("RTT to %s on %s sample result: %d us.\n", debugf("RTT to %s on %s sample result: %d us.\n",
format_address(from), ifp->name, rtt); format_address(from), ifp->name, rtt);
if (valid_rtt(neigh)) if (valid_rtt(neigh)) {
/* Running exponential average. */ /* Running exponential average. */
neigh->rtt = (rtt_exponential_decay * MAX(rtt, 0) neigh->rtt = (ifp->rtt_exponential_decay * MAX(rtt, 0)
+ (256 - rtt_exponential_decay) * neigh->rtt) / 256; + (256 - ifp->rtt_exponential_decay) * neigh->rtt);
else neigh->rtt /= 256;
} else {
/* We prefer to be conservative with new neighbours /* We prefer to be conservative with new neighbours
(higher RTT) */ (higher RTT) */
neigh->rtt = MAX(2*rtt, 0); neigh->rtt = MAX(2*rtt, 0);
}
neigh->rtt_time = now; neigh->rtt_time = now;
} }
return; return;
......
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