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;
unsigned char myid[8];
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 all_wireless = 0;
int default_wireless_hello_interval = -1;
......
......@@ -90,7 +90,6 @@ extern int do_daemonise;
extern const char *logfile, *pidfile, *state_file;
extern int link_detect;
extern int all_wireless;
extern unsigned int rtt_exponential_decay;
extern unsigned char myid[8];
......
......@@ -91,6 +91,9 @@ struct interface {
unsigned short hello_seqno;
unsigned hello_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. */
unsigned int rtt_min;
unsigned int rtt_max;
......
......@@ -611,14 +611,16 @@ parse_packet(const unsigned char *from, struct interface *ifp,
debugf("RTT to %s on %s sample result: %d us.\n",
format_address(from), ifp->name, rtt);
if (valid_rtt(neigh))
if (valid_rtt(neigh)) {
/* Running exponential average. */
neigh->rtt = (rtt_exponential_decay * MAX(rtt, 0)
+ (256 - rtt_exponential_decay) * neigh->rtt) / 256;
else
neigh->rtt = (ifp->rtt_exponential_decay * MAX(rtt, 0)
+ (256 - ifp->rtt_exponential_decay) * neigh->rtt);
neigh->rtt /= 256;
} else {
/* We prefer to be conservative with new neighbours
(higher RTT) */
neigh->rtt = MAX(2*rtt, 0);
}
neigh->rtt_time = now;
}
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