Commit 9987e139 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Change interval accounting to use milliseconds.

parent 28f2cfc3
......@@ -161,16 +161,16 @@ main(int argc, char **argv)
}
} else if(strcmp(*arg, "-h") == 0) {
SHIFTE();
wireless_hello_interval = atoi(*arg);
wireless_hello_interval = atoi(*arg) * 1000;
} else if(strcmp(*arg, "-H") == 0) {
SHIFTE();
wired_hello_interval = atoi(*arg);
wired_hello_interval = atoi(*arg) * 1000;
} else if(strcmp(*arg, "-i") == 0) {
SHIFTE();
idle_hello_interval = atoi(*arg);
idle_hello_interval = atoi(*arg) * 1000;
} else if(strcmp(*arg, "-u") == 0) {
SHIFTE();
update_interval = atoi(*arg);
update_interval = atoi(*arg) * 1000;
} else if(strcmp(*arg, "-k") == 0) {
SHIFTE();
kernel_metric = atoi(*arg);
......@@ -248,18 +248,18 @@ main(int argc, char **argv)
}
if(wireless_hello_interval <= 0)
wireless_hello_interval = 6;
wireless_hello_interval = 6000;
if(wired_hello_interval <= 0)
wired_hello_interval = 30;
wired_hello_interval = 30000;
if(update_interval <= 0)
update_interval =
MIN(MAX(wireless_hello_interval * 5, wired_hello_interval),
70);
70000);
if(seqno_interval <= 0)
seqno_interval = MAX(wireless_hello_interval - 1, 2);
seqno_interval = MAX(wireless_hello_interval - 100, 2000);
if(do_daemonise) {
if(logfile == NULL)
......
......@@ -476,7 +476,7 @@ send_hello(struct network *net)
{
int changed;
changed = update_hello_interval(net);
send_hello_noupdate(net, net->hello_interval * 100);
send_hello_noupdate(net, (net->hello_interval + 9) / 10);
if(changed)
send_ihu(NULL, net);
}
......@@ -752,7 +752,7 @@ send_update(struct network *net, int urgent,
if(prefix == NULL) {
send_self_update(net, 0);
delay_jitter(&net->update_time, &net->update_timeout,
update_interval * 1000);
update_interval);
} else if(find_xroute(prefix, plen)) {
buffer_update(net, prefix, plen);
}
......@@ -780,7 +780,7 @@ send_update(struct network *net, int urgent,
if(routes[i].installed)
buffer_update(net, routes[i].src->prefix, routes[i].src->plen);
delay_jitter(&net->update_time, &net->update_timeout,
update_interval * 1000);
update_interval);
}
schedule_update_flush(net, urgent);
}
......@@ -788,7 +788,7 @@ send_update(struct network *net, int urgent,
void
update_myseqno(int force)
{
if(force || seqno_time + seqno_interval < now.tv_sec) {
if(force || seqno_time + (seqno_interval + 500) / 1000 < now.tv_sec) {
myseqno = seqno_plus(myseqno, 1);
seqno_time = now.tv_sec;
}
......@@ -813,7 +813,7 @@ send_self_update(struct network *net, int force_seqno)
debugf("Sending self update to %s.\n", net->ifname);
delay_jitter(&net->self_update_time, &net->self_update_timeout,
net->self_update_interval * 1000);
net->self_update_interval);
for(i = 0; i < numxroutes; i++) {
send_update(net, 0, xroutes[i].prefix, xroutes[i].plen);
}
......@@ -881,7 +881,7 @@ send_ihu(struct neighbour *neigh, struct network *net)
}
}
delay_jitter(&net->ihu_time, &net->ihu_timeout,
net->ihu_interval * 1000);
net->ihu_interval);
} else {
int rxcost;
......@@ -892,8 +892,8 @@ send_ihu(struct neighbour *neigh, struct network *net)
rxcost = neighbour_rxcost(neigh);
if(net->ihu_interval * 100 <= 0xFFFF)
interval = net->ihu_interval * 100;
if((net->ihu_interval + 9) / 10 <= 0xFFFF)
interval = (net->ihu_interval + 9) / 10;
else
interval = 0;
......
......@@ -60,7 +60,6 @@ add_network(char *ifname)
nets[numnets].buffered = 0;
nets[numnets].bucket_time = now.tv_sec;
nets[numnets].bucket = 0;
nets[numnets].hello_interval = 10000;
nets[numnets].hello_seqno = (random() & 0xFFFF);
numnets++;
return &nets[numnets - 1];
......@@ -101,7 +100,7 @@ update_hello_interval(struct network *net)
}
net->self_update_interval =
MAX(15 + net->hello_interval / 2, net->hello_interval);
MAX(15000 + net->hello_interval / 2, net->hello_interval);
return rc;
}
......@@ -111,7 +110,7 @@ update_hello_interval(struct network *net)
unsigned int
jitter(struct network *net)
{
unsigned interval = net->hello_interval * 1000;
unsigned interval = net->hello_interval;
interval = MIN(interval, 2000);
return (interval / 2 + random() % interval) / 4;
}
......@@ -119,7 +118,7 @@ jitter(struct network *net)
unsigned int
update_jitter(struct network *net, int urgent)
{
unsigned interval = net->hello_interval * 1000;
unsigned interval = net->hello_interval;
if(urgent)
interval = MIN(interval, 100);
else
......@@ -244,13 +243,13 @@ network_up(struct network *net, int up)
/* But don't bail out for now. */
}
delay_jitter(&net->hello_time, &net->hello_timeout,
net->hello_interval * 1000);
net->hello_interval);
delay_jitter(&net->ihu_time, &net->ihu_timeout,
net->ihu_interval * 1000);
net->ihu_interval);
delay_jitter(&net->self_update_time, &net->self_update_timeout,
net->self_update_interval * 1000);
net->self_update_interval);
delay_jitter(&net->update_time, &net->update_timeout,
update_interval * 1000);
update_interval);
send_hello(net);
send_request(net, NULL, 0, 0, 0, 0);
} else {
......
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