node: determine roamability when selecting neighbors

Currently, the neighbor report list is sorted based on the total amount
of roam actions to and from the specific foreign nodes.

This does not take into account that nodes might not be created at the
same time. When a popular neighbor node reboots, it's roam actions are
reset and it's ranking might not recover for a long amount of time
depending on how long the local node is already running.

Change this shotcoming to take into account the timestamp at which a
node was created. This way, the ranking depends on the amount of roam
actions relative to the nodes uptime / seen-time.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer
2021-09-29 19:17:11 +02:00
parent d0cd65b762
commit 5ec713b8f3

15
node.c
View File

@@ -56,13 +56,14 @@ usteer_node_higher_bssid(struct usteer_node *node1, struct usteer_node *node2)
}
static struct usteer_node *
usteer_node_more_roam_interactions(struct usteer_node *node, struct usteer_node *ref)
usteer_node_higher_roamability(struct usteer_node *node, struct usteer_node *ref)
{
int roam_actions_node, roam_actions_ref;
uint64_t roamability_node, roamability_ref;
roam_actions_node = node->roam_source + node->roam_destination;
roam_actions_ref = ref->roam_source + ref->roam_destination;
if (roam_actions_node < roam_actions_ref)
roamability_node = ((uint64_t)(node->roam_source + node->roam_destination)) * current_time / ((current_time - node->created) + 1);
roamability_ref = ((uint64_t)(ref->roam_source + ref->roam_destination)) * current_time / ((current_time - ref->created) + 1);
if (roamability_node < roamability_ref)
return ref;
return node;
@@ -86,8 +87,8 @@ usteer_node_better_neighbor(struct usteer_node *node, struct usteer_node *ref)
if (!node)
return ref;
n1 = usteer_node_more_roam_interactions(node, ref);
n2 = usteer_node_more_roam_interactions(ref, node);
n1 = usteer_node_higher_roamability(node, ref);
n2 = usteer_node_higher_roamability(ref, node);
if (n1 == n2)
return n1;