From f3019290265d2d1534b048d8decae09ab012d327 Mon Sep 17 00:00:00 2001 From: gardners Date: Tue, 13 Sep 2011 03:19:54 +0930 Subject: [PATCH] Rejigged node structure to include score and advertisment history information that can be used to help us prioritise which nodes get advertised when. --- mphlr.h | 10 ++++++++-- overlay_route.c | 21 +++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/mphlr.h b/mphlr.h index 1ee845c7..2b20566a 100644 --- a/mphlr.h +++ b/mphlr.h @@ -747,9 +747,15 @@ typedef struct overlay_node_observation { typedef struct overlay_node { unsigned char sid[SID_SIZE]; int neighbour_id; /* 0=not a neighbour */ - long long last_observation_time_ms; - unsigned int last_first_hand_observation_time_sec; int most_recent_observation_id; + int best_link_score; + int best_observation; + unsigned int last_first_hand_observation_time_sec; + long long last_observation_time_ms; + /* When did we last advertise this node on each interface, and what score + did we advertise? */ + long long most_recent_advertisment[OVERLAY_MAX_INTERFACES]; + unsigned char most_recent_advertised_score[OVERLAY_MAX_INTERFACES]; overlay_node_observation observations[OVERLAY_MAX_OBSERVATIONS]; } overlay_node; diff --git a/overlay_route.c b/overlay_route.c index ec1cc0f4..a7c5d92a 100644 --- a/overlay_route.c +++ b/overlay_route.c @@ -412,7 +412,13 @@ overlay_node *overlay_route_find_node(unsigned char *sid,int createP) for(i=0;iobservations[o].rx_time)/1000; if (discounted_score<0) discounted_score=0; n->observations[o].corrected_score=discounted_score; + if (discounted_score>best_score) { + best_score=discounted_score; + best_observation=o; + } } } + + /* Remember new reachability information */ + n->best_link_score=best_score; + n->best_observation=best_observation; + return 0; }