Commit e3e18efc authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Rework penalising of clients with large hello intervals.

parent c99e9473
...@@ -196,19 +196,21 @@ neighbour_rxcost(struct neighbour *neigh) ...@@ -196,19 +196,21 @@ neighbour_rxcost(struct neighbour *neigh)
if(neigh->reach == 0) if(neigh->reach == 0)
return INFINITY; return INFINITY;
else if(neigh->network->wired) { else if(neigh->network->wired) {
if((neigh->reach & 0xE000) != 0) if((neigh->reach & 0xE000) != 0) {
return neigh->network->cost; int c = neigh->network->cost;
else int d = now.tv_sec - neigh->hello_time;
if(d >= 60)
c *= (d - 40) / 20.0;
return MIN(c, INFINITY);
} else {
return INFINITY; return INFINITY;
}
} else { } else {
int r = (neigh->reach & 0x7FFF) + ((neigh->reach & 0x8000) >> 1); int r = (neigh->reach & 0x7FFF) + ((neigh->reach & 0x8000) >> 1);
double c = (((double)0xC000 * 0x100) / r); double c = (((double)0xC000 * 0x100) / r);
int d = now.tv_sec - neigh->hello_time;
/* Avoid neighbours that give poor feedback */ if(d >= 40)
if(neigh->hello_interval == 0) c *= (d - 20) / 20.0;
c += 256 + (now.tv_sec - neigh->hello_time) * 10;
else if(neigh->hello_interval >= 20)
c *= (neigh->hello_interval / 20.0);
return MIN((int)(c + neigh->network->cost + 0.5), INFINITY); return MIN((int)(c + neigh->network->cost + 0.5), INFINITY);
} }
......
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