From a8046f7dd95862e78aff99302a56693ce2a8fada Mon Sep 17 00:00:00 2001 From: Nevadita <nevadita.chatterjee@iopsys.eu> Date: Mon, 23 May 2022 10:33:06 +0000 Subject: [PATCH] Optimizing topology request to all nodes in algo --- src/topo_ieee1905.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/topo_ieee1905.c b/src/topo_ieee1905.c index 4007c60..3e731fd 100644 --- a/src/topo_ieee1905.c +++ b/src/topo_ieee1905.c @@ -216,11 +216,11 @@ int topologyd_node_add(struct topologyd_private *priv, struct node *node) * * Intial state: * Nbr(P) = {N0,..Nn} <== immediate neighbors of P. - * G{P, N0,..Nn} <== graph of all known nodes at P. * * Step 1: * for all Ni in G: - * Send Topology Request to Ni. + * (a) Send Topology Request to Ni neighbors + * (b) Send Topology Request to Ni * * Step 2: * Read Topology Response from Ni. @@ -233,8 +233,9 @@ int topologyd_node_add(struct topologyd_private *priv, struct node *node) */ void topologyd_algo_run(struct topologyd_private *priv) { - struct node *p; + struct node *p = NULL, *node = NULL; int i, j; + int is_selfnode = 0; //struct linkMetricQueryTLV tlv_metric; if (priv->algo_running) @@ -254,17 +255,18 @@ void topologyd_algo_run(struct topologyd_private *priv) dbg("The total nodes are %d", p->nbr_num); for (j = 0; j < p->nbr_num; j++) { - dbg("sending req to " MACFMT "\n", MAC2STR(p->nbr_list[j].nbr_macid)); - topologyd_send_ieee1905_topology_query(priv, p->nbr_list[j].nbr_macid); - dbg("Processing " MACFMT " AL\n", MAC2STR(p->nbr_list[j].nbr_macid)); + /*Here we need to see if the node exist in our hash table then req will + * be sent from below */ + node = node_lookup(priv->topo.node_htable, p->nbr_list[j].nbr_macid); + if (!node) { + dbg("sending req to " MACFMT "\n", MAC2STR(p->nbr_list[j].nbr_macid)); + topologyd_send_ieee1905_topology_query(priv, p->nbr_list[j].nbr_macid); + dbg("Processing " MACFMT " AL\n", MAC2STR(p->nbr_list[j].nbr_macid)); + } } /*here we send the topology query to selfnode each*/ /*time the algo runs to keep self node updated */ - topologyd_send_ieee1905_topology_query(priv, NULL); -//TEST - //topologyd_send_ieee1905_query(priv, NULL, CMDU_TYPE_HIGHER_LAYER_RESPONSE, NULL); - //topologyd_send_ieee1905_query(priv, NULL, CMDU_TYPE_LINK_METRIC_RESPONSE, NULL); -//TEST + for (i = 0; i < NODE_HTABLE_SIZE; i++) { if (hlist_empty(&priv->topo.node_htable[i])) continue; @@ -275,8 +277,13 @@ void topologyd_algo_run(struct topologyd_private *priv) continue; for (j = 0; j < p->nbr_num; j++) { - dbg("sending req to " MACFMT "\n", MAC2STR(p->nbr_list[j].nbr_macid)); - topologyd_send_ieee1905_topology_query(priv, p->nbr_list[j].nbr_macid); + node = NULL; + is_selfnode = memcmp(&priv->selfnode, p->nbr_list[j].nbr_macid, 6); + node = node_lookup(priv->topo.node_htable, p->nbr_list[j].nbr_macid); + if (!node && is_selfnode) { + dbg("sending req to " MACFMT "\n", MAC2STR(p->nbr_list[j].nbr_macid)); + topologyd_send_ieee1905_topology_query(priv, p->nbr_list[j].nbr_macid); + } } //Here we also need to send the topology query to neighbors dbg("sending topology req to " MACFMT "\n", MAC2STR(p->hwaddr)); -- GitLab