From 5ec713b8f334c7f9fe368572a46264cf6f82eb91 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Wed, 29 Sep 2021 19:17:11 +0200 Subject: [PATCH] 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 --- node.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/node.c b/node.c index 00ffb99..8e0b30d 100644 --- a/node.c +++ b/node.c @@ -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; -- 2.30.2